Introduction
Components
- Accordion
- Action Sheet
- Alert
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- AvoidKeyboard
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Charts
Installation
pnpm dlx bna-ui add bottom-sheet
Usage
import { BottomSheet, useBottomSheet } from '@/components/ui/bottom-sheet';
function MyComponent() {
const { isVisible, open, close } = useBottomSheet();
return (
<>
<Button onPress={open}>Open Bottom Sheet</Button>
<BottomSheet
isVisible={isVisible}
onClose={close}
title='Settings'
snapPoints={[0.3, 0.6, 0.9]}
>
<Text>Your content here</Text>
</BottomSheet>
</>
);
}
Examples
Default
With Title
Custom Snap Points
Form Content
List Content
No Backdrop Dismiss
Custom Styling
Menu Options
API Reference
BottomSheet
The main bottom sheet component that provides a modal interface sliding from the bottom.
Prop | Type | Default | Description |
---|---|---|---|
isVisible | boolean | - | Controls the visibility of the bottom sheet. |
onClose | function | - | Callback function called when the sheet is closed. |
children | ReactNode | - | The content to display inside the bottom sheet. |
snapPoints | number[] | [0.3, 0.6, 0.9] | Array of snap points as percentages of screen height. |
enableBackdropDismiss | boolean | true | Whether tapping the backdrop should dismiss the sheet. |
title | string | - | Optional title to display at the top of the sheet. |
style | ViewStyle | - | Additional styles to apply to the bottom sheet container. |
useBottomSheet Hook
A custom hook that provides state management for the bottom sheet.
const { isVisible, open, close, toggle } = useBottomSheet();
Returns
Property | Type | Description |
---|---|---|
isVisible | boolean | Current visibility state of the sheet. |
open | function | Function to open the bottom sheet. |
close | function | Function to close the bottom sheet. |
toggle | function | Function to toggle the sheet visibility. |
Gesture Support
The BottomSheet component includes built-in gesture support:
- Pan Gesture: Drag the sheet up and down to resize
- Snap Points: The sheet will snap to predefined heights
- Velocity Detection: Fast downward swipes will close the sheet
- Boundary Limits: Prevents dragging beyond defined limits
Snap Points
Snap points define the available heights for the bottom sheet as percentages of screen height:
0.3
= 30% of screen height0.6
= 60% of screen height0.9
= 90% of screen height
The sheet will automatically snap to the nearest point when gestures end.
Animation
The component uses React Native Reanimated for smooth animations:
- Spring Animation: Natural feeling spring animations for opening/closing
- Gesture Responsiveness: Real-time tracking of pan gestures
- Backdrop Fade: Smooth opacity transitions for the backdrop
Accessibility
The BottomSheet component includes accessibility features:
- Modal Semantics: Proper modal behavior for screen readers
- Focus Management: Traps focus within the sheet when open
- Gesture Alternatives: Provides non-gesture ways to interact
- Backdrop Dismiss: Can be disabled for better accessibility control
Best Practices
- Content Height: Ensure your content works well with different snap points
- Backdrop Dismiss: Consider disabling for critical actions
- Loading States: Show loading indicators for async content
- Error Handling: Provide clear error states within the sheet
- Keyboard Handling: Account for keyboard appearance with form content