Select
버튼으로 트리거되어 사용자가 옵션 목록에서 선택할 수 있게 합니다.
도움말
도움말
도움말
설치
사용법
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Theme" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="light">Light</SelectItem>
<SelectItem value="dark">Dark</SelectItem>
<SelectItem value="system">System</SelectItem>
</SelectGroup>
</SelectContent>
</Select>KRDS 정렬
- 분류: Radix/shadcn
Selectcompound API를 유지하는 KRDS-styled 컴포넌트입니다.SelectTrigger,SelectContent,SelectItem등 공개 구조를 그대로 사용합니다. - KRDS 적용: trigger 높이, popup surface, focus/invalid 상태가 KRDS form control 기준에 맞춰 조정되어 있습니다.
- 사용 권장: 복잡한 custom select가 필요할 때 사용하고, 브라우저 기본 select가 더 적합한 폼에는
Native Select문서를 우선 검토하세요.
구성
다음 조합으로 Select:
Select
├── SelectTrigger
│ └── SelectValue
└── SelectContent
├── SelectGroup
│ ├── SelectLabel
│ ├── SelectItem
│ └── SelectItem
├── SelectSeparator
└── SelectGroup
├── SelectLabel
├── SelectItem
└── SelectItem예제
Align Item With Trigger
SelectContent의 position prop으로 정렬 방식을 제어합니다. position="item-aligned"(기본값)은 선택된 항목이 trigger 위로 맞춰지고, position="popper"는 popup이 trigger edge에 맞춰집니다.
Toggle to align the item with the trigger.
Groups
SelectGroup, SelectLabel, SelectSeparator로 항목을 그룹화하세요.
Scrollable
A select with many items that scrolls.
Disabled
Invalid
Add the data-invalid attribute to the Field component and the aria-invalid attribute to the SelectTrigger component to show an error state.
<Field data-invalid>
<FieldLabel>Fruit</FieldLabel>
<SelectTrigger aria-invalid>
<SelectValue />
</SelectTrigger>
</Field>Please select a fruit.
RTL
RTL 지원을 활성화하려면 RTL 설정 가이드를 참고하세요.
API 참조
Radix UI Select API 문서를 참고하세요.