- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
Installation#
pnpm dlx shadcn@latest add @zui/sheetThe CLI writes components/ui/sheet.tsx, lib/motion.ts and lib/overlay.ts, installs Direction, Button, Icon,
Text and Utils, and adds @rn-primitives/dialog, @rn-primitives/portal,
lucide-react-native, react-native-reanimated and react-native-worklets. The content draws in the app's
PortalHost; see Add a portal host. Without one it draws nothing,
and logs an error saying so while the app is in development.
Usage#
import { Button } from '@/components/ui/button';
import {
Sheet,
SheetClose,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@/components/ui/sheet';
import { Text } from '@/components/ui/text';<Sheet>
<SheetTrigger asChild>
<Button variant="outline">
<Text>Open</Text>
</Button>
</SheetTrigger>
<SheetContent side="bottom">
<SheetHeader>
<SheetTitle>Edit profile</SheetTitle>
<SheetDescription>Make changes to your profile here.</SheetDescription>
</SheetHeader>
<SheetFooter>
<SheetClose asChild>
<Button>
<Text>Save changes</Text>
</Button>
</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>API reference#
Sheet#
Takes every prop of React Native's View, plus open, defaultOpen and onOpenChange(open). Without open
the Sheet holds its own state, starting from defaultOpen.
SheetTrigger and SheetClose#
Take every prop of React Native's Pressable. SheetTrigger opens the Sheet and SheetClose closes it. Pass
asChild to make a Button do it. Focus returns to the trigger when the Sheet closes.
SheetContent#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
side | 'top' | 'right' | 'bottom' | 'left' | 'right' |
showCloseButton | boolean | true |
portalHost | string | - |
side attaches the panel to that edge: across the top or bottom at its content's height, or down the left or right
at three quarters of the screen's width. The panel is a modal dialog named by its SheetTitle, over a dimmed
overlay. Accessibility focus moves into it as it opens. A press on the overlay, the Android back button, the iOS
escape gesture (a two-finger Z) and Escape on the web close it. It fades in while sliding 2.5rem in from its side
over 200ms, and out the same way. When the system asks for reduced motion it appears and goes at once.
VoiceOver stays inside the sheet while it is open. TalkBack does once the app hides its screens from screen readers while an overlay is shown, as Add a portal host shows; the web hides the rest of the page itself.
The panel runs to the screen's edge, under the status bar or the home indicator. Pad it by the safe area's insets
where it meets them, such as with useSafeAreaInsets from react-native-safe-area-context.
SheetHeader and SheetFooter#
Take every prop of React Native's View. The footer is pushed to the end of the panel and stacks its children.
SheetTitle and SheetDescription#
Take every prop of Text. The title is a heading.
Right to left#
A left or right sheet stays on the side it names, as upstream's does, which places it with left-0 and
right-0. A device the system lays out right to left draws left styles on the right, unless the app turned
that off with I18nManager.swapLeftAndRightInRTL(false); there the sheet slides in from the side it is drawn on.
That follows the system's direction, not a provider's, since a provider changes no layout on a device.
Differences from upstream#
- Upstream's
renderprop becomesasChild, as on every native item. - On iOS, VoiceOver does not read
aria-labelledby, so the sheet is not announced by its title's name there. Focus moves into the content, where the title is the first thing read. Android and the web read the name. - The overlay fades over the sheet's 200ms rather than upstream's 150ms, as one animation drives both.
- Upstream caps a side panel at
max-w-smfromsmand blurs the screen behind the overlay. A phone is narrower thansm, and React Native has no backdrop blur. - Upstream's animation runs whatever the system's motion setting. The native one is skipped when the system asks for reduced motion.
portalHostis added, for an app that draws overlays into aPortalHostof its own.