셀렉트 (Select)
Select 컴포넌트는 드롭다운 선택 인터페이스를 제공하는 컴포넌트예요. popover, bottom-sheet, dialog 세 가지 표현 모드를 지원하며, 트리거, 값 표시, 항목, 인디케이터 등 복합 파트로 구성돼요.
출처: 문서
본문
Import
import { Select } from 'heroui-native';
Anatomy
<Select>
<Select.Trigger>
<Select.Value />
<Select.TriggerIndicator />
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content>
<Select.Close />
<Select.ListLabel>...</Select.ListLabel>
<Select.Item>
<Select.ItemLabel />
<Select.ItemDescription>...</Select.ItemDescription>
<Select.ItemIndicator />
</Select.Item>
</Select.Content>
</Select.Portal>
</Select>
- Select: 열림/닫힘 상태와 값 선택을 관리하고 자식 컴포넌트에 컨텍스트를 제공하는 메인 컨테이너예요.
- Select.Trigger: 셀렉트 표시 여부를 토글하는 클릭 가능한 요소예요. press 핸들러로 모든 자식 요소를 감싸요.
variantprop ('default'또는'unstyled')을 지원해요. - Select.Value: 선택된 값 또는 placeholder 텍스트를 표시해요. 선택이 변경되면 자동으로 업데이트됩니다. 선택 상태에 따라 스타일링이 바뀌어요.
- Select.TriggerIndicator: 열림/닫힘 상태를 보여주는 선택적 시각적 표시기예요. 기본적으로 애니메이션 chevron 아이콘을 렌더링하며, 셀렉트가 열리거나 닫힐 때 회전해요.
- Select.Portal: 셀렉트 콘텐츠를 다른 콘텐츠 위의 포털 레이어에 렌더링해요. 올바른 스태킹과 포지셔닝을 보장해요.
- Select.Overlay: 선택적 배경 오버레이예요. 바깥 클릭을 캡처하도록 투명하거나 반투명할 수 있어요.
- Select.Content: popover(포지셔닝이 있는 플로팅), bottom sheet 모달, dialog 모달의 세 가지 표현 모드를 가진 셀렉트 콘텐츠 컨테이너예요.
- Select.Close: 셀렉트의 닫기 버튼이에요. 커스텀 자식 또는 기본 닫기 아이콘을 사용할 수 있어요.
- Select.ListLabel: 미리 스타일링된 타이포그래피가 있는 항목 목록의 라벨이에요.
- Select.Item: 선택 가능한 옵션 항목이에요. 선택 상태와 press 이벤트를 처리해요.
- Select.ItemLabel: 항목의 라벨 텍스트를 표시해요.
- Select.ItemDescription: muted 스타일링이 있는 선택적 항목 설명 텍스트예요.
- Select.ItemIndicator: 선택된 항목에 표시되는 선택적 표시기예요. 기본적으로 체크 아이콘을 렌더링해요.
Usage
기본 사용법 (Basic Usage)
Select 컴포넌트는 복합 파트를 사용해 드롭다운 선택 인터페이스를 만들어요.
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="1" label="Option 1" />
<Select.Item value="2" label="Option 2" />
</Select.Content>
</Select.Portal>
</Select>
값 표시와 함께 (With Value Display)
Value 컴포넌트를 사용해 트리거에 선택된 값을 표시해요.
<Select>
<Select.Trigger>
<Select.Value placeholder="Choose an option" />
<Select.TriggerIndicator />
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="apple" label="Apple" />
<Select.Item value="orange" label="Orange" />
<Select.Item value="banana" label="Banana" />
</Select.Content>
</Select.Portal>
</Select>
Popover 표현 (Popover Presentation)
자동 포지셔닝이 있는 플로팅 콘텐츠에는 popover 표현을 사용해요.
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" placement="bottom" align="center">
<Select.Item value="1" label="Item 1" />
<Select.Item value="2" label="Item 2" />
</Select.Content>
</Select.Portal>
</Select>
너비 제어 (Width Control)
width prop으로 셀렉트 콘텐츠의 너비를 제어해요. 이것은 popover 표현에서만 동작해요.
{
/* Fixed width in pixels */
}
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" width={280}>
<Select.Item value="1" label="Item 1" />
</Select.Content>
</Select.Portal>
</Select>;
{
/* Match trigger width */
}
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" width="trigger">
<Select.Item value="1" label="Item 1" />
</Select.Content>
</Select.Portal>
</Select>;
{
/* Full width (100%) */
}
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" width="full">
<Select.Item value="1" label="Item 1" />
</Select.Content>
</Select.Portal>
</Select>;
{
/* Auto-size to content (default) */
}
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" width="content-fit">
<Select.Item value="1" label="Item 1" />
</Select.Content>
</Select.Portal>
</Select>;
바텀 시트 표현 (Bottom Sheet Presentation)
모바일에 최적화된 선택 경험에는 바텀 시트를 사용해요.
<Select presentation="bottom-sheet">
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="bottom-sheet" snapPoints={['35%']}>
<Select.Item value="1" label="Item 1" />
<Select.Item value="2" label="Item 2" />
</Select.Content>
</Select.Portal>
</Select>
다이얼로그 표현 (Dialog Presentation)
중앙 정렬된 모달 스타일 선택에는 dialog 표현을 사용해요.
<Select presentation="dialog">
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="dialog">
<Select.Close />
<Select.ListLabel>Choose an option</Select.ListLabel>
<Select.Item value="1" label="Item 1" />
<Select.Item value="2" label="Item 2" />
</Select.Content>
</Select.Portal>
</Select>
커스텀 항목 콘텐츠 (Custom Item Content)
커스텀 콘텐츠와 인디케이터로 항목의 모양을 커스터마이징해요.
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="us" label="United States">
<View className="flex-row items-center gap-3 flex-1">
<Text>🇺🇸</Text>
<Select.ItemLabel />
</View>
<Select.ItemIndicator />
</Select.Item>
<Select.Item value="uk" label="United Kingdom">
<View className="flex-row items-center gap-3 flex-1">
<Text>🇬🇧</Text>
<Select.ItemLabel />
</View>
<Select.ItemIndicator />
</Select.Item>
</Select.Content>
</Select.Portal>
</Select>
렌더 함수와 함께 (With Render Function)
Select.Item에 렌더 함수를 사용해 상태에 접근하고 선택에 따라 콘텐츠를 커스터마이징해요.
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="us" label="United States">
{({ isSelected, value, isDisabled }) => (
<>
<View className="flex-row items-center gap-3 flex-1">
<Text>🇺🇸</Text>
<Select.ItemLabel
className={
isSelected ? 'text-accent font-medium' : 'text-foreground'
}
/>
</View>
<Select.ItemIndicator />
</>
)}
</Select.Item>
<Select.Item value="uk" label="United Kingdom">
{({ isSelected }) => (
<>
<View className="flex-row items-center gap-3 flex-1">
<Text>🇬🇧</Text>
<Select.ItemLabel
className={
isSelected ? 'text-accent font-medium' : 'text-foreground'
}
/>
</View>
<Select.ItemIndicator />
</>
)}
</Select.Item>
</Select.Content>
</Select.Portal>
</Select>
항목 설명과 함께 (With Item Description)
추가 컨텍스트를 위해 항목에 설명을 추가해요.
<Select>
<Select.Trigger>...</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="basic" label="Basic">
<View className="flex-1">
<Select.ItemLabel />
<Select.ItemDescription>
Essential features for personal use
</Select.ItemDescription>
</View>
<Select.ItemIndicator />
</Select.Item>
</Select.Content>
</Select.Portal>
</Select>
트리거 인디케이터와 함께 (With Trigger Indicator)
셀렉트의 열림/닫힘 상태를 보여주는 시각적 표시기를 추가해요. 셀렉트가 열리거나 닫힐 때 표시기가 회전합니다.
<Select>
<Select.Trigger>
<Select.Value placeholder="Select one" />
<Select.TriggerIndicator />
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="1" label="Option 1" />
<Select.Item value="2" label="Option 2" />
</Select.Content>
</Select.Portal>
</Select>
unstyled 변형의 커스텀 트리거 (Custom Trigger with Unstyled Variant)
Button 같은 다른 컴포넌트로 커스텀 트리거를 구성할 때 unstyled 변형을 사용해요.
<Select>
<Select.Trigger variant="unstyled" asChild>
<Button variant="secondary">
<Select.Value placeholder="Select..." />
<Select.TriggerIndicator />
</Button>
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="1" label="Option 1" />
<Select.Item value="2" label="Option 2" />
</Select.Content>
</Select.Portal>
</Select>
제어 모드 (Controlled Mode)
셀렉트 상태를 프로그래매틱하게 제어해요.
const [value, setValue] = useState();
const [isOpen, setIsOpen] = useState(false);
<Select
value={value}
onValueChange={setValue}
isOpen={isOpen}
onOpenChange={setIsOpen}
>
<Select.Trigger>
<Select.Value placeholder="Select..." />
<Select.TriggerIndicator />
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover">
<Select.Item value="1" label="Option 1" />
<Select.Item value="2" label="Option 2" />
</Select.Content>
</Select.Portal>
</Select>;
Example
import { Select, Separator } from 'heroui-native';
import React, { useState } from 'react';
type SelectOption = {
value: string;
label: string;
};
const US_STATES: SelectOption[] = [
{ value: 'CA', label: 'California' },
{ value: 'NY', label: 'New York' },
{ value: 'TX', label: 'Texas' },
{ value: 'FL', label: 'Florida' },
];
export default function SelectExample() {
const [value, setValue] = useState<SelectOption | undefined>();
return (
<Select value={value} onValueChange={setValue}>
<Select.Trigger>
<Select.Value placeholder="Select one" />
<Select.TriggerIndicator />
</Select.Trigger>
<Select.Portal>
<Select.Overlay />
<Select.Content presentation="popover" width="trigger">
<Select.ListLabel className="mb-2">Choose a state</Select.ListLabel>
{US_STATES.map((state, index) => (
<React.Fragment key={state.value}>
<Select.Item value={state.value} label={state.label} />
{index < US_STATES.length - 1 && <Separator />}
</React.Fragment>
))}
</Select.Content>
</Select.Portal>
</Select>
);
}
더 많은 예시는 GitHub 저장소에서 찾을 수 있어요.
API Reference
Select
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 셀렉트의 콘텐츠 |
value |
SelectOption | SelectOption[] |
- | 선택된 값 (제어 모드) |
onValueChange |
(value: SelectOption | SelectOption[]) => void |
- | 값이 변경될 때의 콜백 |
defaultValue |
SelectOption | SelectOption[] |
- | 기본 선택 값 (비제어 모드) |
isOpen |
boolean |
- | 셀렉트가 열렸는지 여부 (제어 모드) |
isDefaultOpen |
boolean |
- | 처음 렌더링될 때 셀렉트가 열려 있는지 여부 (비제어 모드) |
onOpenChange |
(isOpen: boolean) => void |
- | 셀렉트 열림 상태가 변경될 때의 콜백 |
isDisabled |
boolean |
false |
셀렉트가 비활성화되었는지 여부 |
presentation |
'popover' | 'bottom-sheet' | 'dialog' |
'popover' |
셀렉트 콘텐츠의 표현 모드 |
animation |
SelectRootAnimation |
- | 애니메이션 구성 |
asChild |
boolean |
false |
자식 요소로 렌더링할지 여부 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props 지원 |
SelectRootAnimation
Select 컴포넌트의 애니메이션 구성이에요. 값으로는:
false또는"disabled": 루트 애니메이션만 비활성화"disable-all": 자식을 포함한 모든 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용object: 커스텀 애니메이션 구성
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | 'disable-all' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
entering.value |
SpringAnimationConfig | TimingAnimationConfig |
- | 셀렉트가 열릴 때의 애니메이션 구성 |
exiting.value |
SpringAnimationConfig | TimingAnimationConfig |
- | 셀렉트가 닫힐 때의 애니메이션 구성 |
SpringAnimationConfig
| prop | type | default | description |
|---|---|---|---|
type |
'spring' |
- | 애니메이션 유형 ('spring'이어야 함) |
config |
WithSpringConfig |
- | Reanimated spring 애니메이션 구성 |
TimingAnimationConfig
| prop | type | default | description |
|---|---|---|---|
type |
'timing' |
- | 애니메이션 유형 ('timing'이어야 함) |
config |
WithTimingConfig |
- | Reanimated timing 애니메이션 구성 |
Select.Trigger
| prop | type | default | description |
|---|---|---|---|
variant |
'default' | 'unstyled' |
'default' |
트리거의 변형. 'default'는 미리 스타일링된 컨테이너 스타일 적용, 'unstyled'는 기본 스타일 제거 |
children |
ReactNode |
- | 트리거 요소 콘텐츠 |
className |
string |
- | 트리거의 추가 CSS 클래스 |
asChild |
boolean |
true |
자식 요소로 렌더링할지 여부 |
isDisabled |
boolean |
- | 트리거가 비활성화되었는지 여부 |
...PressableProps |
PressableProps |
- | 모든 표준 React Native Pressable props 지원 |
Select.Value
| prop | type | default | description |
|---|---|---|---|
placeholder |
string |
- | 값이 선택되지 않았을 때의 placeholder 텍스트 |
className |
string |
- | value의 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props 지원 |
참고: value 컴포넌트는 선택 상태에 따라 다른 텍스트 색상을 자동 적용해요:
- 값이 선택되었을 때:
text-foreground - 값이 선택되지 않았을 때(placeholder):
text-field-placeholder
Select.TriggerIndicator
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 커스텀 표시기 콘텐츠. 기본은 애니메이션 chevron 아이콘 |
className |
string |
- | 트리거 표시기의 추가 CSS 클래스 |
style |
ViewStyle |
- | 트리거 표시기의 커스텀 스타일 |
iconProps |
SelectTriggerIndicatorIconProps |
- | chevron 아이콘 구성 |
animation |
SelectTriggerIndicatorAnimation |
- | 애니메이션 구성 |
isAnimatedStyleActive |
boolean |
true |
애니메이션 스타일(react-native-reanimated) 활성화 여부 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props 지원 |
참고: 다음 스타일 속성은 애니메이션이 차지하므로 className으로 설정할 수 없어요:
transform(특히rotate) — 열림/닫힘 회전 전환을 위해 애니메이션됨
이 속성을 커스터마이징하려면 animation prop을 사용해요. 애니메이션 스타일을 완전히 비활성화하고 className 또는 style prop으로 직접 사용하려면 isAnimatedStyleActive={false}로 설정해요.
SelectTriggerIndicatorIconProps
| prop | type | default | description |
|---|---|---|---|
size |
number |
16 |
아이콘 크기 |
color |
string |
- | 아이콘 색상 (기본: 전경 테마 색상) |
SelectTriggerIndicatorAnimation
Select.TriggerIndicator 컴포넌트의 애니메이션 구성이에요. 값으로는:
false또는"disabled": 모든 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용 (0°에서 -180° 회전)object: 커스텀 애니메이션 구성
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
rotation.value |
[number, number] |
[0, -180] |
회전 값 [closed, open] (도 단위) |
rotation.springConfig |
WithSpringConfig |
{ damping: 140, stiffness: 1000, mass: 4 } |
회전의 spring 애니메이션 구성 |
Select.Portal
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 포털 콘텐츠 (필수) |
disableFullWindowOverlay |
boolean |
false |
iOS에서 true면 FullWindowOverlay 대신 View 사용. 요소 검사기 활성화; 네이티브 모달 위에 오버레이가 나타나지 않음 |
unstable_accessibilityContainerViewIsModal |
boolean |
false |
VoiceOver가 오버레이 창을 모달 컨테이너로 취급할지 제어. true면 VoiceOver가 오버레이 안의 요소로 제한됨. iOS 전용. 불안정: react-native-screens 업데이트로 변경될 수 있음 |
className |
string |
- | 포털 컨테이너의 추가 CSS 클래스 |
hostName |
string |
- | 포털 호스트 요소의 선택적 이름 |
forceMount |
boolean |
- | DOM에서 컴포넌트를 강제 마운트할지 여부 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props 지원 |
Select.Overlay
| prop | type | default | description |
|---|---|---|---|
className |
string |
- | 오버레이의 추가 CSS 클래스 |
animation |
SelectOverlayAnimation |
- | 애니메이션 구성 |
isAnimatedStyleActive |
boolean |
true |
애니메이션 스타일(react-native-reanimated) 활성화 여부 |
closeOnPress |
boolean |
true |
오버레이를 누를 때 셀렉트를 닫을지 여부 |
forceMount |
boolean |
- | DOM에서 컴포넌트를 강제 마운트할지 여부 |
asChild |
boolean |
false |
자식 요소로 렌더링할지 여부 |
...Animated.ViewProps |
Animated.ViewProps |
- | 모든 Reanimated Animated.View props 지원 |
SelectOverlayAnimation
Select.Overlay 컴포넌트의 애니메이션 구성이에요. 값으로는:
false또는"disabled": 모든 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용 (bottom-sheet/dialog는 progress 기반 opacity, popover는 Keyframe 애니메이션)object: 커스텀 애니메이션 구성
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
opacity.value |
[number, number, number] |
[0, 1, 0] |
opacity 값 [idle, open, close] (bottom-sheet/dialog 표현용) |
entering |
EntryOrExitLayoutType |
- | 등장 전환용 커스텀 Keyframe 애니메이션 (popover 표현용) |
exiting |
EntryOrExitLayoutType |
- | 퇴장 전환용 커스텀 Keyframe 애니메이션 (popover 표현용) |
Select.Content (Popover 표현)
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 셀렉트 콘텐츠 |
width |
number | 'trigger' | 'content-fit' | 'full' |
'content-fit' |
콘텐츠의 너비 크기 전략 |
presentation |
'popover' |
'popover' |
셀렉트의 표현 모드 |
placement |
'top' | 'bottom' | 'left' | 'right' |
'bottom' |
트리거 기준 콘텐츠의 배치 |
align |
'start' | 'center' | 'end' |
'center' |
배치 축을 따른 정렬 |
avoidCollisions |
boolean |
true |
뷰포트 가장자리에 가까울 때 배치를 뒤집을지 여부 |
offset |
number |
8 |
트리거 요소로부터의 거리(픽셀) |
alignOffset |
number |
0 |
정렬 축을 따른 오프셋(픽셀) |
className |
string |
- | 콘텐츠 컨테이너의 추가 CSS 클래스 |
animation |
SelectContentPopoverAnimation |
- | 애니메이션 구성 |
forceMount |
boolean |
- | DOM에서 컴포넌트를 강제 마운트할지 여부 |
insets |
Insets |
- | 포지셔닝 시 존중할 화면 가장자리 인셋 |
asChild |
boolean |
false |
자식 요소로 렌더링할지 여부 |
...Animated.ViewProps |
Animated.ViewProps |
- | 모든 Reanimated Animated.View props 지원 |
SelectContentPopoverAnimation
Select.Content 컴포넌트(popover 표현)의 애니메이션 구성이에요. 값으로는:
false또는"disabled": 모든 애니메이션 비활성화true또는undefined: 기본 Keyframe 애니메이션 (placement에 기반한 translateY/translateX, scale, opacity)object:entering및/또는exitingKeyframe 애니메이션이 있는 커스텀 애니메이션 구성
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
entering |
EntryOrExitLayoutType |
- | 등장 전환용 커스텀 Keyframe 애니메이션 (기본: placement 기반 translateY/translateX, scale, opacity, 200ms) |
exiting |
EntryOrExitLayoutType |
- | 퇴장 전환용 커스텀 Keyframe 애니메이션 (기본: 등장 애니메이션을 미러링, 150ms) |
Select.Content (Bottom Sheet 표현)
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 바텀 시트 콘텐츠 |
presentation |
'bottom-sheet' |
- | 셀렉트의 표현 모드 |
contentContainerClassName |
string |
- | 콘텐츠 컨테이너의 추가 CSS 클래스 |
...BottomSheetProps |
BottomSheetProps |
- | 모든 @gorhom/bottom-sheet props 지원 |
Select.Content (Dialog 표현)
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 다이얼로그 콘텐츠 |
presentation |
'dialog' |
- | 셀렉트의 표현 모드 |
classNames |
{ wrapper?: string; content?: string } |
- | wrapper와 content의 추가 CSS 클래스 |
styles |
Partial> |
- | 다이얼로그 콘텐츠의 다양한 부분 스타일 |
animation |
SelectContentAnimation |
- | 애니메이션 구성 |
isSwipeable |
boolean |
true |
다이얼로그 콘텐츠를 스와이프로 닫을 수 있는지 여부 |
forceMount |
boolean |
- | DOM에서 컴포넌트를 강제 마운트할지 여부 |
asChild |
boolean |
false |
자식 요소로 렌더링할지 여부 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props 지원 |
styles
| prop | type | description |
|---|---|---|
wrapper |
ViewStyle |
wrapper 컨테이너 스타일 |
content |
ViewStyle |
다이얼로그 콘텐츠 스타일 |
SelectContentAnimation
Select.Content 컴포넌트(dialog 표현)의 애니메이션 구성이에요. 값으로는:
false또는"disabled": 모든 애니메이션 비활성화true또는undefined: 기본 Keyframe 애니메이션 (scale과 opacity 전환)object:entering및/또는exitingKeyframe 애니메이션이 있는 커스텀 애니메이션 구성
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
entering |
EntryOrExitLayoutType |
- | 등장 전환용 커스텀 Keyframe 애니메이션 (기본: scale과 opacity, 200ms) |
exiting |
EntryOrExitLayoutType |
- | 퇴장 전환용 커스텀 Keyframe 애니메이션 (기본: 등장 애니메이션을 미러링, 150ms) |
Select.Close
Select.Close는 CloseButton을 확장하고, 눌리면 셀렉트 닫기를 자동으로 처리해요.
Select.ListLabel
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 라벨 텍스트 콘텐츠 |
className |
string |
- | 목록 라벨의 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props 지원 |
Select.Item
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode | ((props: SelectItemRenderProps) => ReactNode) |
- | 커스텀 항목 콘텐츠. 기본은 라벨과 인디케이터, 또는 렌더 함수 |
value |
any |
- | 이 항목에 연결된 값 (필수) |
label |
string |
- | 이 항목의 라벨 텍스트 (필수) |
isDisabled |
boolean |
false |
이 항목이 비활성화되었는지 여부 |
className |
string |
- | 항목의 추가 CSS 클래스 |
...PressableProps |
PressableProps |
- | 모든 표준 React Native Pressable props 지원 |
SelectItemRenderProps
children에 렌더 함수를 사용하면 다음 props가 제공됩니다:
| property | type | description |
|---|---|---|
isSelected |
boolean |
이 항목이 현재 선택되었는지 여부 |
value |
string |
항목의 값 |
isDisabled |
boolean |
항목이 비활성화되었는지 여부 |
Select.ItemLabel
| prop | type | default | description |
|---|---|---|---|
className |
string |
- | 항목 라벨의 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props 지원 |
Select.ItemDescription
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 설명 텍스트 콘텐츠 |
className |
string |
- | 항목 설명의 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props 지원 |
Select.ItemIndicator
| prop | type | default | description |
|---|---|---|---|
children |
ReactNode |
- | 커스텀 인디케이터 콘텐츠. 기본은 체크 아이콘 |
className |
string |
- | 항목 인디케이터의 추가 CSS 클래스 |
iconProps |
SelectItemIndicatorIconProps |
- | 체크 아이콘 구성 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props 지원 |
SelectItemIndicatorIconProps
| prop | type | default | description |
|---|---|---|---|
size |
number |
16 |
아이콘 크기 |
color |
string |
theme accent-soft-foreground color | 아이콘 색상 |
Hooks
useSelect
Select 루트 컨텍스트에 접근하는 훅이에요. 셀렉트 상태와 제어 함수를 반환해요.
import { useSelect } from 'heroui-native';
const {
isOpen,
onOpenChange,
isDefaultOpen,
isDisabled,
presentation,
triggerPosition,
setTriggerPosition,
contentLayout,
setContentLayout,
nativeID,
value,
onValueChange,
} = useSelect();
반환 값 (Return Value)
| property | type | description |
|---|---|---|
isOpen |
boolean |
셀렉트가 현재 열렸는지 여부 |
onOpenChange |
(open: boolean) => void |
열림 상태를 변경하는 콜백 |
isDefaultOpen |
boolean | undefined |
셀렉트가 기본적으로 열려 있는지 여부 (비제어 모드) |
isDisabled |
boolean | undefined |
셀렉트가 비활성화되었는지 여부 |
presentation |
'popover' | 'bottom-sheet' | 'dialog' |
셀렉트 콘텐츠의 표현 모드 |
triggerPosition |
LayoutPosition | null |
뷰포트 기준 트리거 요소의 위치 |
setTriggerPosition |
(position: LayoutPosition | null) => void |
트리거 요소의 위치를 업데이트 |
contentLayout |
LayoutRectangle | null |
셀렉트 콘텐츠의 레이아웃 측정값 |
setContentLayout |
(layout: LayoutRectangle | null) => void |
콘텐츠 레이아웃 측정값을 업데이트 |
nativeID |
string |
셀렉트 인스턴스의 고유 식별자 |
value |
SelectOption | SelectOption[] |
현재 선택된 옵션 |
onValueChange |
(option: SelectOption | SelectOption[]) => void |
선택된 값이 변경될 때 호출되는 콜백 |
참고: 이 훅은 Select 컴포넌트 안에서 사용해야 해요. 셀렉트 컨텍스트 밖에서 호출하면 오류가 발생합니다.
useSelectAnimation
커스텀 컴포넌트 또는 복합 컴포넌트에서 Select 애니메이션 상태 값에 접근하는 훅이에요.
import { useSelectAnimation } from 'heroui-native';
const { selectState, progress, isDragging, isGestureReleaseAnimationRunning } =
useSelectAnimation();
반환 값 (Return Value)
| property | type | description |
|---|---|---|
progress |
SharedValue<number> |
애니메이션의 진행 값 (0=idle, 1=open, 2=close) |
isDragging |
SharedValue<boolean> |
셀렉트 콘텐츠가 현재 드래그 중인지 여부 |
isGestureReleaseAnimationRunning |
SharedValue<boolean> |
제스처 릴리스 애니메이션이 현재 실행 중인지 여부 |
참고: 이 훅은 Select 컴포넌트 안에서 사용해야 해요. 셀렉트 애니메이션 컨텍스트 밖에서 호출하면 오류가 발생합니다.
SelectOption
| property | type | description |
|---|---|---|
value |
string |
옵션의 값 |
label |
string |
옵션의 라벨 텍스트 |
useSelectItem
Select Item 컨텍스트에 접근하는 훅이에요. 항목의 값과 라벨을 반환해요.
import { useSelectItem } from 'heroui-native';
const { itemValue, label } = useSelectItem();
반환 값 (Return Value)
| property | type | description |
|---|---|---|
itemValue |
string |
현재 항목의 값 |
label |
string |
현재 항목의 라벨 텍스트 |
특별 참고 사항 (Special Notes)
요소 검사기 (Element Inspector, iOS)
Select는 iOS에서 FullWindowOverlay를 사용해요. 개발 중 React Native 요소 검사기를 활성화하려면 Select.Portal에 disableFullWindowOverlay={true}를 설정해요. 단점: 비활성화하면 셀렉트 드롭다운이 네이티브 모달 위에 나타나지 않아요.
네이티브 모달 (Native Modal, iOS)
Select가 네이티브 모달(presentation: 'modal' | 'formSheet' | 'pageSheet')로 표시된 화면 안에서 열리면, 드롭다운이 위로 이동해 렌더링될 수 있어요. 새 아키텍처(Fabric)에서 react-native-screens는 RNSModalScreen을 Fabric 루트로 표시하므로, 트리거의 위치는 모달의 원점을 기준으로 보고되는 반면 FullWindowOverlay(드롭다운이 마운트되는 곳)는 iOS 애플리케이션 창에 고정됩니다. safeAreaInsets.top을 offset에 더해 보정해요:
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const insets = useSafeAreaInsets();
<Select.Content presentation="popover" offset={insets.top + 10}>
...
</Select.Content>;