suiss/ui · Component
Sheet
A panel that slides in from an edge of the screen over the page.
Sheet is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Sheet is built on the dialog primitive of the chosen base. SheetTrigger opens it, and SheetContent renders the panel in a portal over a dimming backdrop. Inside, SheetHeader holds a SheetTitle and SheetDescription, and SheetFooter holds actions. SheetClose closes the sheet from any element.
The panel floats inset from the screen edge with rounded corners and slides in from its side. Use a sheet for supporting tasks, such as editing details or showing navigation, that should keep the page in context. For short, centered confirmations, use Dialog or AlertDialog.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Composition
Use the following composition to build a Sheet:
Examples
Sides
Use the side prop on SheetContent to open the sheet from each of the four edges.
Left
A sheet with side="left", rendered open.
Bottom
A sheet with side="bottom", rendered open along the bottom edge.
Without close button
Set showCloseButton={false} on SheetContent to remove the built-in close button.
With close label
Set closeLabel="Done" to replace the icon close button with a text button.
Accessibility
- The panel has the
dialogrole.SheetTitlegives it an accessible name andSheetDescriptionan accessible description. - Opening the sheet moves focus inside it.
Escapecloses the sheet, and focus returns to the trigger.
Escapecloses the sheet, and focus returns to the trigger. SetisKeyboardDismissDisabledonSheetContentto turnEscapeoff.
- The icon close button has the hidden label
Close.
API Reference
Sheet
The root that holds the open state.
Also accepts the props of the primitive part it wraps.
Use defaultOpen for an uncontrolled sheet, or open with onOpenChange to control it. Use the render prop on SheetTrigger and SheetClose to render them as a Button.
Use defaultOpen for an uncontrolled sheet, or open with onOpenChange to control it. Set asChild on SheetTrigger and SheetClose to render a Button in their place.
Use defaultOpen for an uncontrolled sheet, or isOpen with onOpenChange to control it. The Button placed first inside Sheet opens it, and a Button with slot="close" closes it.
SheetTrigger
The element that opens the sheet.
Also accepts the props of the primitive part it wraps.
SheetClose
An element that closes the sheet when pressed.
Also accepts the props of the primitive part it wraps.
SheetContent
The sliding panel, rendered in a portal with a backdrop.
| Prop | Type | Default |
|---|---|---|
side | "top" | "right" | "bottom" | "left" | "right" |
showCloseButton | boolean | true |
closeLabel | string | - |
| Prop | Type | Default |
|---|---|---|
side | "top" | "right" | "bottom" | "left" | "right" |
showCloseButton | boolean | true |
closeLabel | string | - |
isDismissable | boolean | true |
isKeyboardDismissDisabled | boolean | false |
isDismissable closes the sheet when the backdrop is pressed, and isKeyboardDismissDisabled stops Escape from closing it.
Also accepts the props of the primitive part it wraps.
side is the edge the sheet slides in from; slide directions flip in right-to-left layouts. Left and right sheets are 3/4 of the screen wide, up to max-w-sm from the sm breakpoint. By default the panel shows an icon close button in the top corner; set closeLabel to show that text instead, or showCloseButton={false} to remove it.
SheetHeader
A padded stack for the title and description.
Also accepts the props of React.ComponentProps<"div">.
SheetFooter
A padded stack for actions, pushed to the bottom of the panel.
Also accepts the props of React.ComponentProps<"div">.
The footer sits at the bottom of the panel with mt-auto.
SheetTitle
The sheet's title, which names the dialog.
Also accepts the props of the primitive part it wraps.
SheetDescription
Supporting text, which describes the dialog.
Also accepts the props of the primitive part it wraps.
Each part sets a data-slot, such as sheet-content or sheet-overlay, for styling. The panel also sets data-side.
Web preview
Sheet is built on the drawer primitive. SheetContent renders in a portal, above a dimmed overlay, as a rounded floating panel inset from the screen edges and the safe area. It enters and exits with a Reanimated fade-and-slide from its side and can be dismissed by swiping toward that edge.
Use right or left for navigation and detail panels that span the screen height, and top or bottom for short panels that span the width. For snap points and a drag handle, use Drawer instead.
Installation
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/sheet.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/sheet.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/sheet.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Default
Web preview
Sides
One sheet for each side: top, right, bottom and left.
Web preview
With close label
A bottom sheet whose close button reads "Done" instead of showing an icon.
Web preview
Accessibility
- The panel has the
dialogrole and is labeled bySheetTitlewhen one is present. - It is modal by default, so VoiceOver keeps focus inside the sheet.
- The VoiceOver escape gesture and the Android back button close the sheet.
- The icon-only close button has the accessibility label "Close".
- Animations respect the system reduce motion setting.
API Reference
Sheet
Root that holds the open state.
Also accepts the props of DrawerPrimitive.RootProps.
Use open, defaultOpen and onOpenChange for controlled or uncontrolled use. Sheet also accepts modal, disablePointerDismissal, onOpenChangeComplete and actionsRef. The swipe direction follows the side of its content. Use SheetTrigger and SheetClose with render to turn a Button into a trigger or close control.
SheetContent
The panel, rendered in a portal with an overlay and an optional close button.
| Prop | Type | Default |
|---|---|---|
portalHost | string | - |
side | SheetSide | "right" |
showCloseButton | boolean | true |
closeLabel | string | - |
Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Popup>.
side is the edge the sheet slides in from. Side sheets are three quarters of the screen width, capped at max-w-sm on larger screens. A close button is shown in the top corner by default; set closeLabel to show a text button instead of the X icon, or showCloseButton={false} to remove it. portalHost names the portal host to render into. On iOS the sheet renders inside a FullWindowOverlay from react-native-screens, so it appears above native modals.
SheetHeader
Column for the title and description.
Also accepts the props of ViewProps.
The header adds end padding so the title does not run under the close button.
SheetFooter
Column of actions pushed to the bottom of the panel.
Also accepts the props of ViewProps.
SheetTitle
Heading that labels the sheet.
Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Title>.
SheetDescription
Secondary text under the title.
Also accepts the props of React.ComponentProps<typeof DrawerPrimitive.Description>.
.sheet
| Parameter | Type | Default |
|---|---|---|
isPresented | Binding<Bool> | - |
side | Edge | - |
content | () -> Content | - |
SheetContent
The panel, rendered in a portal with an overlay and an optional close button.
| Parameter | Type | Default |
|---|---|---|
showCloseButton | Bool | true |
closeLabel | LocalizedStringKey? | nil |
content | () -> Content | - |
SheetHeader
Column for the title and description.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
SheetFooter
Column of actions pushed to the bottom of the panel.
| Parameter | Type | Default |
|---|---|---|
content | () -> Content | - |
SheetSide
Values: Top, Right, Bottom, Left.
Sheet
Root that holds the open state.
| Parameter | Type | Default |
|---|---|---|
open | Boolean | - |
onOpenChange | (Boolean) -> Unit | - |
modifier | Modifier | Modifier |
side | SheetSide: Top | Right | Bottom | Left | SheetSide.Right |
showCloseButton | Boolean | true |
closeLabel | String? | null |
content | @Composable ColumnScope.() -> Unit | - |
SheetHeader
Column for the title and description.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
SheetFooter
Column of actions pushed to the bottom of the panel.
Receiver: ColumnScope.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
content | @Composable ColumnScope.() -> Unit | - |
SheetTitle
Heading that labels the sheet.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |
SheetDescription
Secondary text under the title.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
modifier | Modifier | Modifier |