BottomSheet (바텀 시트)
BottomSheet는 화면 아래쪽에서 애니메이션과 함께 슬라이드 업되는 바텀 시트를 표시하는 컴포넌트예요. 스와이프로 닫는 제스처를 지원하며, @gorhom/bottom-sheet를 기반으로 렌더링해요. 스냅 포인트, 블러 오버레이, 키보드 인식 입력 등 다양한 고급 기능을 제공해요.
출처: 문서
본문
Import
import { BottomSheet } from 'heroui-native';
Anatomy
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay>...</BottomSheet.Overlay>
<BottomSheet.Content>
<BottomSheet.Close />
<BottomSheet.Title>...</BottomSheet.Title>
<BottomSheet.Description>...</BottomSheet.Description>
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
- BottomSheet: 열림 상태를 관리하고 하위 컴포넌트에 컨텍스트를 제공하는 루트 컴포넌트예요.
- BottomSheet.Trigger: 눌렀을 때 바텀 시트를 여는 pressable 요소예요.
- BottomSheet.Portal: 전체 창 오버레이와 함께 포털에 바텀 시트 콘텐츠를 렌더링해요.
- BottomSheet.Overlay: 화면을 덮는 배경 오버레이로, 보통 눌렀을 때 바텀 시트를 닫아요.
- BottomSheet.Content: 제스처 지원을 위해 @gorhom/bottom-sheet를 사용하는 메인 바텀 시트 컨테이너예요.
- BottomSheet.Close: 바텀 시트의 닫기 버튼이에요. 커스텀 children을 받거나 기본 닫기 아이콘을 사용해요.
- BottomSheet.Title: 시맨틱 헤딩 역할과 접근성 연결을 가진 바텀 시트 제목 텍스트예요.
- BottomSheet.Description: 접근성 연결과 함께 추가 컨텍스트를 제공하는 바텀 시트 설명 텍스트예요.
Usage
Basic Bottom Sheet
타이틀, 설명, 닫기 버튼이 있는 간단한 바텀 시트예요.
<BottomSheet>
<BottomSheet.Trigger asChild>
<Button>Open Bottom Sheet</Button>
</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay />
<BottomSheet.Content>
<BottomSheet.Close />
<BottomSheet.Title>...</BottomSheet.Title>
<BottomSheet.Description>...</BottomSheet.Description>
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
Detached Bottom Sheet
바닥 가장자리에서 분리되어 커스텀 간격을 가진 바텀 시트예요.
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay />
<BottomSheet.Content
detached={true}
bottomInset={insets.bottom + 12}
className="mx-4"
backgroundClassName="rounded-[32px]"
>
...
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
Scrollable with Snap Points
여러 스냅 포인트와 스크롤 가능한 콘텐츠를 가진 바텀 시트예요.
BottomSheet.Content 안에서 스크롤 가능한 콘텐츠를 올바르게 작동시키려면 다음 기본 원칙을 따르세요:
@gorhom/bottom-sheet의 스크롤 가능한 컴포넌트를 사용하세요 (예:BottomSheetScrollView,BottomSheetFlatList,BottomSheetSectionList,BottomSheetVirtualizedList).react-native의 일반ScrollView/FlatList는 시트가 스크롤 제스처를 가로채게 해요.BottomSheet.Content에서 over-drag와 동적 크기 조정을 비활성화해서 시트가 콘텐츠와 함께 커지거나 스크롤을 흡수하지 않게 하세요:enableOverDrag={false}와enableDynamicSizing={false}.contentContainerClassName="h-full"(또는 다른 고정 높이)을 통해BottomSheet.Content에 고정 높이를 주세요. 제약은 스크롤 가능한 자식이 아니라BottomSheet.Content에 있어야 해요 — 스크롤 가능한 요소가 내부에서 스크롤하려면 경계가 있는 부모가 필요해요.
import { BottomSheetScrollView } from '@gorhom/bottom-sheet';
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay />
<BottomSheet.Content
snapPoints={['40%', '80%']}
enableOverDrag={false}
enableDynamicSizing={false}
contentContainerClassName="h-full"
>
<BottomSheetScrollView>...</BottomSheetScrollView>
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>;
스티키 푸터(BottomSheetFooter)가 있는 전체 예제는 GitHub 저장소에서 볼 수 있어요.
Blur Overlay
내장 blur variant를 사용하면 애니메이션 블러 배경(backdrop)을 만들 수 있어요. iOS 전용이며 선택적 expo-blur 패키지가 필요해요. 다른 플랫폼(또는 패키지가 없는 경우)에서는 기본 단색 배경으로 대체돼요. 라이브러리 테마가 glass이면 blur variant가 기본으로 사용돼요.
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay variant="blur" blurViewProps={{ intensity: 40 }} />
<BottomSheet.Content>...</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
Custom Overlay
블러 효과 같은 커스텀 콘텐츠로 기본 오버레이를 교체해요.
import { useBottomSheet, useBottomSheetAnimation } from 'heroui-native';
import { StyleSheet, Pressable } from 'react-native';
import { interpolate, useDerivedValue } from 'react-native-reanimated';
import { AnimatedBlurView } from './animated-blur-view';
import { useUniwind } from 'uniwind';
export const BottomSheetBlurOverlay = () => {
const { theme } = useUniwind();
const { onOpenChange } = useBottomSheet();
const { progress } = useBottomSheetAnimation();
const blurIntensity = useDerivedValue(() => {
return interpolate(progress.get(), [0, 1, 2], [0, 40, 0]);
});
return (
<Pressable
style={StyleSheet.absoluteFill}
onPress={() => onOpenChange(false)}
>
<AnimatedBlurView
blurIntensity={blurIntensity}
tint={theme === 'dark' ? 'dark' : 'systemUltraThinMaterialDark'}
style={StyleSheet.absoluteFill}
/>
</Pressable>
);
};
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheetBlurOverlay />
<BottomSheet.Content>...</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
With Keyboard-Aware Input
BottomSheet.Content 안에서 Input 또는 InputOTP를 렌더링할 때 useBottomSheetAwareHandlers 훅을 사용해서 키보드 회피 핸들러를 연결해요. 반환된 onFocus / onBlur를 입력에 전달하세요.
Note:
useBottomSheetAwareHandlers는 반드시BottomSheet안에서 사용해야 해요.BottomSheet.Content안에서 렌더링되는 자식 컴포넌트에서 호출하세요 —BottomSheet컨텍스트 밖에서는 반환된 핸들러가 no-op이에요.
스크롤 가능한 콘텐츠의 경우, BottomSheet.Content에 keyboardBehavior="extend"(또는 "interactive")를 구성하고 스크롤 가능한 요소에는 keyboardShouldPersistTaps="handled"를 설정해서 탭이 대상에 도달하기 전에 키보드를 닫지 않게 하세요.
import { BottomSheet, Input, useBottomSheetAwareHandlers } from 'heroui-native';
const BottomSheetTextInput = () => {
const { onFocus, onBlur } = useBottomSheetAwareHandlers();
return <Input placeholder="Type here..." onFocus={onFocus} onBlur={onBlur} />;
};
<BottomSheet>
<BottomSheet.Trigger>...</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay />
<BottomSheet.Content keyboardBehavior="extend">
<BottomSheetTextInput />
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>;
바텀 시트 안의 Input과 InputOTP의 전체 예제를 확인하세요.
Example
import { BottomSheet, Button } from 'heroui-native';
import { useState } from 'react';
import { View } from 'react-native';
import { withUniwind } from 'uniwind';
import Ionicons from '@expo/vector-icons/Ionicons';
const StyledIonicons = withUniwind(Ionicons);
export default function BottomSheetExample() {
const [isOpen, setIsOpen] = useState(false);
return (
<BottomSheet isOpen={isOpen} onOpenChange={setIsOpen}>
<BottomSheet.Trigger asChild>
<Button variant="secondary">Open Bottom Sheet</Button>
</BottomSheet.Trigger>
<BottomSheet.Portal>
<BottomSheet.Overlay />
<BottomSheet.Content>
<View className="items-center mb-5">
<View className="size-20 items-center justify-center rounded-full bg-green-500/10">
<StyledIonicons
name="shield-checkmark"
size={40}
className="text-green-500"
/>
</View>
</View>
<View className="mb-8 gap-2 items-center">
<BottomSheet.Title className="text-center">
Keep yourself safe
</BottomSheet.Title>
<BottomSheet.Description className="text-center">
Update your software to the latest version for better security and
performance.
</BottomSheet.Description>
</View>
<View className="gap-3">
<Button onPress={() => setIsOpen(false)}>Update Now</Button>
<Button variant="tertiary" onPress={() => setIsOpen(false)}>
Later
</Button>
</View>
</BottomSheet.Content>
</BottomSheet.Portal>
</BottomSheet>
);
}
GitHub 저장소에서 더 많은 예제를 볼 수 있어요.
API Reference
BottomSheet
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 바텀 시트 콘텐츠와 트리거 요소 |
isOpen |
boolean |
- | 바텀 시트의 제어된 열림 상태 |
isDefaultOpen |
boolean |
false |
비제어 상태에서의 초기 열림 상태 |
animation |
AnimationRootDisableAll |
- | 애니메이션 구성 |
onOpenChange |
(value: boolean) => void |
- | 열림 상태가 변경될 때 호출되는 콜백 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View prop을 지원해요 |
Animation Configuration
바텀 시트 루트 컴포넌트를 위한 애니메이션 구성이에요. 값은 다음과 같아요:
"disable-all": children을 포함한 모든 애니메이션 비활성화undefined: 기본 애니메이션 사용
BottomSheet.Trigger
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 트리거 요소 콘텐츠 |
asChild |
boolean |
- | 래퍼 없이 자식 요소로 렌더링 |
...TouchableOpacityProps |
TouchableOpacityProps |
- | 모든 표준 React Native TouchableOpacity prop을 지원해요 |
BottomSheet.Portal
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 포털 콘텐츠 (오버레이와 바텀 시트) |
disableFullWindowOverlay |
boolean |
false |
iOS에서 true면 FullWindowOverlay 대신 View를 사용해요. 요소 인스펙터를 활성화하며, 네이티브 모달 위에는 오버레이가 표시되지 않아요 |
unstable_accessibilityContainerViewIsModal |
boolean |
false |
VoiceOver가 오버레이 창을 모달 컨테이너로 취급할지 제어해요. true면 VoiceOver가 오버레이 안의 요소로 제한돼요. iOS 전용. 불안정: react-native-screens 업데이트에 따라 변경될 수 있어요 |
className |
string |
- | 포털 컨테이너를 위한 추가 CSS 클래스 |
style |
StyleProp<ViewStyle> |
- | 포털 컨테이너를 위한 추가 스타일 |
hostName |
string |
- | 특정 컨테이너를 위한 선택적 포털 호스트 이름 |
forceMount |
boolean |
- | 애니메이션 목적으로 닫힌 상태에서도 강제 마운트 |
BottomSheet.Overlay
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 커스텀 오버레이 콘텐츠 |
className |
string |
- | 오버레이를 위한 추가 CSS 클래스 |
style |
ViewStyle |
- | 오버레이 컨테이너를 위한 추가 스타일 |
animation |
Omit<PopupOverlayAnimation, 'entering' | 'exiting'> |
- | 애니메이션 구성 |
variant |
'default' | 'blur' |
'default' ('blur' when the library theme is glass) |
오버레이 variant. 'blur'는 애니메이션 블러 배경을 렌더링해요 (iOS 전용, expo-blur 필요, 그 외에는 'default'로 대체) |
blurViewProps |
BlurViewProps |
- | 'blur' variant가 렌더링하는 BlurView에 전달되는 prop. intensity는 최대 애니메이션 블러 강도를 설정해요 (기본: 75 dark / 50 light) |
isAnimatedStyleActive |
boolean |
true (false for the 'blur' variant) |
애니메이션 스타일(react-native-reanimated)이 활성인지 여부 |
isCloseOnPress |
boolean |
true |
오버레이를 누르면 바텀 시트가 닫히는지 여부 |
...PressableProps |
PressableProps |
- | 모든 표준 React Native Pressable prop을 지원해요 |
Animation Configuration
바텀 시트 오버레이 컴포넌트를 위한 애니메이션 구성이에요. 값은 다음과 같아요:
false또는"disabled": 모든 애니메이션 비활성화true또는undefined: 기본 애니메이션 사용object: 커스텀 애니메이션 구성 (entering과exiting속성 제외)
| prop | type | default | description |
|---|---|---|---|
state |
'disabled' | boolean |
- | 속성을 커스터마이징하는 동안 애니메이션 비활성화 |
opacity.value |
[number, number, number] |
[0, 1, 0] |
Opacity 값 [idle, open, close] |
BottomSheet.Content
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 바텀 시트 콘텐츠 |
className |
string |
- | 바텀 시트 컨테이너를 위한 추가 CSS 클래스 |
containerClassName |
string |
- | 컨테이너를 위한 추가 CSS 클래스 |
contentContainerClassName |
string |
- | 콘텐츠 컨테이너를 위한 추가 CSS 클래스 |
backgroundClassName |
string |
- | 백그라운드를 위한 추가 CSS 클래스 |
handleClassName |
string |
- | 핸들을 위한 추가 CSS 클래스 |
handleIndicatorClassName |
string |
- | 핸들 표시기를 위한 추가 CSS 클래스 |
contentContainerProps |
Omit<BottomSheetViewProps, 'children'> |
- | 콘텐츠 컨테이너를 위한 prop |
animation |
AnimationDisabled |
- | 애니메이션 구성 |
...GorhomBottomSheetProps |
Partial<GorhomBottomSheetProps> |
- | 모든 @gorhom/bottom-sheet prop을 지원해요 |
Note: BottomSheetView, BottomSheetScrollView, BottomSheetFlatList 등 @gorhom/bottom-sheet의 모든 컴포넌트를 콘텐츠 안에서 사용할 수 있어요.
BottomSheet.Close
BottomSheet.Close는 CloseButton을 확장하며, 눌렀을 때 바텀 시트 닫기를 자동으로 처리해요.
BottomSheet.Title
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 타이틀 콘텐츠 |
className |
string |
- | 타이틀을 위한 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text prop을 지원해요 |
BottomSheet.Description
| prop | type | default | description |
|---|---|---|---|
children |
React.ReactNode |
- | 설명 콘텐츠 |
className |
string |
- | 설명을 위한 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text prop을 지원해요 |
Hooks
useBottomSheet
바텀 시트 primitive 컨텍스트에 접근하는 훅이에요.
const { isOpen, onOpenChange } = useBottomSheet();
| property | type | description |
|---|---|---|
isOpen |
boolean |
현재 열림 상태 |
onOpenChange |
(value: boolean) => void |
열림 상태를 변경하는 함수 |
useBottomSheetAnimation
고급 커스터마이징을 위해 바텀 시트 애니메이션 컨텍스트에 접근하는 훅이에요.
const { progress } = useBottomSheetAnimation();
| property | type | description |
|---|---|---|
progress |
SharedValue<number> |
애니메이션 진행도 (0=idle, 1=open, 2=close) |
useBottomSheetAwareHandlers
BottomSheet.Content 안에서 Input 또는 InputOTP가 렌더링될 때 키보드 회피를 위한 onFocus와 onBlur 핸들러를 반환하는 훅이에요. 반드시 BottomSheet 안에서 사용해야 해요 — BottomSheet 컨텍스트 밖에서는 반환된 핸들러가 no-op이에요.
const { onFocus, onBlur } = useBottomSheetAwareHandlers();
| property | type | description |
|---|---|---|
onFocus |
(e: FocusEvent) => void |
바텀 시트에 키보드 대상을 알리는 포커스 핸들러 |
onBlur |
(e: BlurEvent) => void |
바텀 시트 상태에서 키보드 대상을 조건부로 지우는 블러 핸들러 |
Special Notes
Element Inspector (iOS)
BottomSheet는 iOS에서 FullWindowOverlay를 사용하며, 이는 별도의 네이티브 창에 렌더링돼요. 이 때문에 React Native 요소 인스펙터가 깨져요. 개발 중에 인스펙터를 활성화하려면 BottomSheet.Portal에 disableFullWindowOverlay={true}를 설정하세요. 단점: 비활성화하면 바텀 시트가 네이티브 모달 위에 표시되지 않아요.
Handling Close Callbacks
닫기 콜백을 처리할 때는 BottomSheet의 onOpenChange prop을 사용하는 것이 좋아요. 모든 닫기 시나리오(아래로 스와이프, 오버레이 누르기, 닫기 버튼 누르기, 프로그램 방식 닫기 등)에서 안정적으로 호출되기 때문이에요.
<BottomSheet
isOpen={isOpen}
onOpenChange={(value) => {
setIsOpen(value);
if (!value) {
// This callback runs whenever the bottom sheet closes
// regardless of how it was closed
yourCallbackOnClose();
}
}}
>
...
</BottomSheet>
Note: BottomSheet.Content의 onClose prop(@gorhom/bottom-sheet에서 온 것)은 제한이 있어서 아래로 스와이프로 닫을 때만 호출돼요. 오버레이 누르기, 닫기 버튼, 프로그램 방식 닫기로는 호출되지 않아요. 안정적인 닫기 콜백을 위해서는 항상 BottomSheet의 onOpenChange prop을 사용하세요.