Sheet
A modal panel that slides from an edge — filters, details and navigation drawers.
Purpose
Sheet is a modal dialog anchored to an edge of the viewport. It shares Dialog's behaviour; only its
placement differs. ("Drawer" in other libraries.)
Import
import {
Sheet,
SheetBody,
SheetClose,
SheetContent,
SheetDescription,
SheetFooter,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@neshel-ui/components";Usage
import {
Button,
Input,
Sheet,
SheetBody,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@neshel-ui/components";
import { Inline } from "@neshel-ui/layout";
const sides = ["left", "right", "top", "bottom"] as const;
export default function SheetSides() {
return (
<Inline space="3" wrap>
{sides.map((side) => (
<Sheet key={side}>
<SheetTrigger asChild>
<Button variant="outline">Open {side}</Button>
</SheetTrigger>
<SheetContent side={side}>
<SheetHeader>
<SheetTitle>Filters</SheetTitle>
<SheetDescription>Narrow the results ({side} sheet).</SheetDescription>
</SheetHeader>
<SheetBody>
<Input aria-label="Keyword" placeholder="Keyword" />
</SheetBody>
</SheetContent>
</Sheet>
))}
</Inline>
);
}API
SheetProps
Also accepts the props of: @radix-ui/react-dialog.
SheetContentProps
| Prop | Type | Default | Description |
|---|---|---|---|
| closeLabel | string | "Close" | Accessible name of the close button (default "Close"). |
| container | HTMLElement | null | document.body | Portal target (default document.body, wrapped with the trigger's theme). |
| ref | Ref<HTMLDivElement> | — | — |
| showClose | boolean | true | Render a close button with an accessible label (default true). |
| side | SheetSide | "right" | Edge the sheet slides from (default "right"). |
| size | "sm" | "md" | "lg" | "md" | Width (left/right) or height (top/bottom) of the sheet (default "md"). |
Also accepts the props of: @radix-ui/react-dialog, @radix-ui/react-dismissable-layer, @radix-ui/react-primitive, React DOM attributes.
SheetSide
type SheetSide = "left" | "right" | "top" | "bottom"SheetTriggerProps
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLButtonElement> | — | — |
Also accepts the props of: @radix-ui/react-primitive, React DOM attributes.
SheetCloseProps
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLButtonElement> | — | — |
Also accepts the props of: @radix-ui/react-primitive, React DOM attributes.
SheetTitleProps
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLHeadingElement> | — | — |
Also accepts the props of: @radix-ui/react-primitive, React DOM attributes.
SheetDescriptionProps
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<HTMLParagraphElement> | — | — |
Also accepts the props of: @radix-ui/react-primitive, React DOM attributes.
SheetHeader, SheetBody and SheetFooter take the same props as DialogPartProps.
Controlled and uncontrolled
open / defaultOpen / onOpenChange, as Dialog.
Accessibility and keyboard
Identical to Dialog: a title is required, focus is trapped and restored, Escape closes. Swipe gestures are not provided.
Common mistakes
- Building a mobile navigation drawer by hand: MobileMenu and the Sidebar drawer already handle closing after navigation.