Layout
Box
Box 컴포넌트는 Lynx에서 가장 기초적인 레이아웃 표면을 구성하는 컴포넌트입니다.
Installation
npm install @seed-design/lynx-react @seed-design/lynx-cssUsage
import { Box, Text } from "@seed-design/lynx-react";
export function App() {
return (
<Box bg="bg.brandWeak" borderColor="stroke.brandWeak" borderWidth={1} borderRadius="r3" p="x4">
<Text textStyle="t5Bold" color="fg.brand">
Box
</Text>
</Box>
);
}Box는 Lynx 네이티브 <view>를 렌더링합니다. bg, p, borderRadius 같은 스타일 prop은 SEED 토큰을 직접 object style 값으로 변환해 적용합니다.
Lynx에서는 웹 Box처럼 CSS variable을 클래스에 주입하는 방식이 아니라, 지원 가능한 스타일 prop만 직접 계산해 <view style={...}>에 적용합니다.
Box는 편의를 위한 primitive입니다. 많은 항목을 반복 렌더링하는 화면에서는 primitive 컴포넌트와 object style 계산 비용이 누적될 수 있으므로, 앱 코드에서는 native <view>/<text>에 Tailwind utility className을 직접 사용하는 방식을 우선 고려하세요. 패키지 컴포넌트 내부에서는 native tag와 recipe className을 사용하고, inline style은 safe area처럼 런타임 값이 필요한 경우에만 제한적으로 사용합니다.
Props
Prop
Type
bindtouchstart?(() => void) | undefinedbindtouchend?(() => void) | undefinedbindtouchcancel?(() => void) | undefinedbg?(string & {}) | ScopedColorPalette | ScopedColorBg | ScopedColorBanner | undefinedbackground?(string & {}) | ScopedColorPalette | ScopedColorBg | ScopedColorBanner | undefinedcolor?(string & {}) | ScopedColorFg | ScopedColorPalette | undefinedborderColor?(string & {}) | ScopedColorPalette | ScopedColorStroke | undefinedborderWidth?0 | 1 | (string & {}) | undefinedborderTopWidth?0 | 1 | (string & {}) | undefinedborderRightWidth?0 | 1 | (string & {}) | undefinedborderBottomWidth?0 | 1 | (string & {}) | undefinedborderLeftWidth?0 | 1 | (string & {}) | undefinedborderRadius?0 | (string & {}) | "full" | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | undefinedborderTopLeftRadius?0 | (string & {}) | "full" | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | undefinedborderTopRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomRightRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedborderBottomLeftRadius?0 | (string & {}) | "r0_5" | "r1" | "r1_5" | "r2" | "r2_5" | "r3" | "r3_5" | "r4" | "r5" | "r6" | "full" | undefinedwidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxWidth?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedheight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedminHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedmaxHeight?(string & {}) | "full" | Dimension | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | undefinedtop?0 | (string & {}) | undefinedleft?0 | (string & {}) | undefinedright?0 | (string & {}) | undefinedbottom?0 | (string & {}) | undefinedpadding?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedp?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpaddingX?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpx?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpaddingY?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpy?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpaddingTop?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | "safeArea" | undefinedpt?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | "safeArea" | undefinedpaddingRight?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpr?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpaddingBottom?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | "safeArea" | undefinedpb?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | "safeArea" | undefinedpaddingLeft?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedpl?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefineddisplay?"none" | (string & {}) | "flex" | undefinedposition?(string & {}) | "relative" | "absolute" | "fixed" | undefinedoverflowX?(string & {}) | "hidden" | "visible" | undefinedoverflowY?(string & {}) | "hidden" | "visible" | undefinedzIndex?Property.ZIndex | undefinedflexGrow?boolean | Property.FlexGrow | undefinedflexShrink?boolean | Property.FlexShrink | undefinedflexDirection?"row" | (string & {}) | "column" | "rowReverse" | "columnReverse" | undefinedflexWrap?boolean | "nowrap" | "wrap" | undefinedjustifyContent?(string & {}) | "center" | "flexStart" | "flexEnd" | "spaceBetween" | "spaceAround" | undefinedjustifySelf?Property.JustifySelf | undefinedalignItems?(string & {}) | "center" | "stretch" | "flexStart" | "flexEnd" | undefinedalignContent?(string & {}) | "center" | "stretch" | "flexStart" | "flexEnd" | undefinedalignSelf?(string & {}) | "center" | "stretch" | "flexStart" | "flexEnd" | undefinedgap?0 | (string & {}) | "spacingX.betweenChips" | "spacingX.globalGutter" | "spacingY.componentDefault" | "spacingY.navToTitle" | "spacingY.screenBottom" | "spacingY.betweenText" | Dimension | undefinedstyle?CSSProperties | undefinedchildren?React.ReactNodeclassName?string | undefinedbindtap?EventHandler<BaseTouchEvent<Target>> | undefinedmain-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefinedStyle Props
현재 Box에서 여는 스타일 prop은 Lynx에서 안정적으로 검증한 범위로 제한합니다.
| 분류 | Props |
|---|---|
| 색상 | bg, background, color, borderColor |
| 테두리 | borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderRadius와 corner radius props |
| 크기 | width, minWidth, maxWidth, height, minHeight, maxHeight |
| 패딩 | p, px, py, pt, pr, pb, pl과 longhand padding props |
| Flex | display, flexDirection, flexWrap, flexGrow, flexShrink, alignItems, justifyContent, gap |
| 배치 | position, top, right, bottom, left, zIndex, overflowX, overflowY |
명시적인 style prop은 마지막에 merge되므로, 필요한 경우 계산된 스타일을 덮어쓸 수 있습니다.
<Box p="x3" style={{ paddingLeft: "24px" }}>
<Text>paddingLeft만 직접 override</Text>
</Box>웹 버전과의 차이
Lynx Box는 React Box와 다음과 같은 차이가 있습니다.
as,asChild를 지원하지 않습니다. Lynx 컴파일러 제약 때문에 네이티브<view>를 컴포넌트 파일 안에서 직접 렌더링합니다.bgGradient,boxShadow,bleedX,bleedY,unstable_transform처럼 아직 Lynx에서 검증하지 않은 StyleProps는 열지 않습니다.- margin 계열 shorthand는 제공하지 않습니다. 레이아웃 간격은
VStack/HStack의gap또는 명시적인style을 사용합니다. - 이벤트는 웹의
onClick대신 Lynx의bindtap계열 prop을 사용합니다.
Last updated on