# Select Box URL: /lynx/components/select-box Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/select-box.mdx A UI element that uses a container with a clear border to select one or more options from a defined list. Lynx Engine 최소 버전: 3.6 사용 가능 버전: @seed-design/lynx-react@0.6.0, @seed-design/lynx-css@0.10.0 ## Preview ```tsx import "./styles"; import { HStack, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } /> } /> } /> } /> } /> } /> ); } ``` Icon colors are not applied in the document preview. You can verify the actual icon colors by running Lynx Explorer from the QR code tab. ## Installation - npm: npx @seed-design/cli@latest add ui:select-box - pnpm: pnpm dlx @seed-design/cli@latest add ui:select-box - yarn: yarn dlx @seed-design/cli@latest add ui:select-box - bun: bun x @seed-design/cli@latest add ui:select-box ## Props ### Check Select Box #### `CheckSelectBoxGroup` #### `CheckSelectBox` #### `CheckSelectBoxCheckmark` ### Radio Select Box #### `RadioSelectBoxRoot` #### `RadioSelectBoxItem` #### `RadioSelectBoxRadiomark` ## Examples ### Customizing Label You can pass custom content combining multiple elements to the `label` prop. ```tsx import "./styles"; import { Badge, HStack, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; function CustomizedLabel() { return ( <> Melon New ); } export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } /> } description="Elit cupidatat dolore fugiat enim veniam culpa." suffix={} /> } /> } /> } description="Elit cupidatat dolore fugiat enim veniam culpa." suffix={} /> } /> ); } ``` ### Listening to Value Changes `CheckSelectBox` can detect checkbox selection state changes using `onCheckedChange`. `RadioSelectBoxRoot` can detect radio button selection value changes using `onValueChange`. ```tsx import "./styles"; import { useState } from "@lynx-js/react"; import { HStack, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [checkCount, setCheckCount] = useState(0); const [checkLastValue, setCheckLastValue] = useState(null); const [radioCount, setRadioCount] = useState(0); const [radioLastValue, setRadioLastValue] = useState(null); return ( } onCheckedChange={(checked) => { setCheckCount((previous) => previous + 1); setCheckLastValue(checked); }} /> onCheckedChange called: {checkCount} times, last value:{" "} {checkLastValue === null ? "-" : JSON.stringify(checkLastValue)} { setRadioCount((previous) => previous + 1); setRadioLastValue(value); }} > } /> } /> onValueChange called: {radioCount} times, last value: {radioLastValue ?? "-"} ); } ``` ### Grid Layout (Columns) You can arrange items in multiple columns using the `columns` prop. If `columns` is greater than 1, the `layout` of child elements is automatically set to `"vertical"`. If needed, you can override the layout of individual items by setting the `layout` prop directly. ```tsx import "./styles"; import IconDiamond from "@karrotmarket/lynx-multicolor-icon/IconDiamond"; import IconIcecreamcone from "@karrotmarket/lynx-multicolor-icon/IconIcecreamcone"; import { VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } label="옵션 1" description="layout=vertical" suffix={} /> } label="옵션 2" description="layout=vertical" suffix={} /> } defaultChecked layout="horizontal" label="layout=horizontal" description="layout을 horizontal로 오버라이드" suffix={} /> } label="옵션 4" description="layout=vertical" suffix={} /> } label="옵션 1" suffix={} /> } label="옵션 2" suffix={} /> } label="layout=horizontal" description="layout을 horizontal로 오버라이드" layout="horizontal" suffix={} /> } label="옵션 4" suffix={} /> } label="옵션 5" suffix={} /> } label="옵션 6" suffix={} /> ); } ``` ### With Suffix You can display a checkmark, radio mark, or custom element using the `suffix` prop. You can use `CheckSelectBoxCheckmark` and `RadioSelectBoxRadiomark`, or pass any free-form element such as an icon or text. ```tsx import "./styles"; import IconPersonCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPersonCircleLine"; import { HStack, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } /> +1,000원} /> } /> } /> +1,000원} /> } /> ); } ``` ### Collapsible Footer You can display additional content with the `footer` prop. You can control the footer display conditions with the `footerVisibility` prop. - `"when-selected"` (default): Display only when the item is selected - `"when-not-selected"`: Display only when the item is not selected - `"always"`: Always display ```tsx import "./styles"; import { HStack, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { CheckSelectBox, CheckSelectBoxCheckmark, CheckSelectBoxGroup, RadioSelectBoxItem, RadioSelectBoxRadiomark, RadioSelectBoxRoot, } from "@/components/ui/select-box"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } footer={선택되었을 때만 보입니다.} /> } footerVisibility="always" footer={항상 보입니다.} /> } footerVisibility="when-not-selected" footer={ 선택되지 않았을 때만 보입니다. } /> } footer={선택되었을 때만 보입니다.} /> } footerVisibility="always" footer={항상 보입니다.} /> } footerVisibility="when-not-selected" footer={ 선택되지 않았을 때만 보입니다. } /> ); } ``` ## Differences from Web Version Lynx `Select Box` has the following differences from the React version. - **React Hook Form not supported**: Lynx does not have a native form submission model, so we do not provide React Hook Form examples. - **No field wrapper**: We do not provide integration with Fieldset and RadioGroupField from React Registry, or field label, description, and error message connections. - **No form submission**: We do not provide hidden input, `inputProps`, `name`, `required`, or `invalid`. - **No keyboard focus**: Uses native tap and accessibility navigation instead of browser keyboard focus. - **Accessibility**: Uses Lynx accessibility roles and selection values instead of HTML ARIA.