Back to Shark UI

Sheet

docs/components/sheet

latest10.4 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Sheet

Copy Markdown

Content that slides in from the screen edge.

DocsAPI

PreviewCode

Open

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/sheet

Anatomy#

Sheet
├── SheetTrigger
└── SheetContent
    ├── SheetHeader
    │ ├── SheetTitle
    │ └── SheetDescription
    ├── SheetBody
    └── SheetFooter
        └── SheetClose

Usage#

import { 
  Sheet, 
  SheetContent, 
  SheetDescription, 
  SheetHeader, 
  SheetTitle, 
  SheetTrigger 
} from "@/components/ui/sheet";
<Sheet>
  <SheetTrigger>Open</SheetTrigger>
  <SheetContent>
    <SheetHeader>
      <SheetTitle>Sheet Title</SheetTitle>     
      <SheetDescription>Sheet Description</SheetDescription>
    </SheetHeader>
  </SheetContent>
</Sheet>

Controlled#

Use open and onOpenChange on the root to control the sheet state.

PreviewCode

Open ControlledOpen Uncontrolled

Sides#

Control which side the sheet slides in from using the side prop.

PreviewCode

RightLeftBottom

Examples#

Inset Variant#

Use the variant="inset" prop to add padding. The sheet appears as a floating card.

PreviewCode

Open

Scrollable#

Use SheetBody to make the content area scrollable while keeping header and footer fixed.

PreviewCode

Open

No Close Button#

Use the showCloseButton={false} prop to hide the close button in the top right corner.

PreviewCode

Open

Close behavior#

Use closeOnInteractOutside and closeOnEscape props to prevent closing on outside click and escape.

PreviewCode

No close on outside clickNo close on Escape

Non-Modal#

Use modal={false} to allow interaction with elements outside the sheet.

PreviewCode

Open

Custom spacing#

Use [--space:--spacing("value")] on SheetContent to adjust internal padding.

Default spacing is --spacing(6).

PreviewCode

Open

You can use breakpoint utilities to change the internal spacing at different screen sizes.

md:[--space:--spacing(6)] lg:[--space:--spacing(8)]

API Reference#

Sheet#

Root component. Uses Ark UI Dialog. Controls open state and slide direction.

PropTypeDefault
openboolean-
defaultOpenbooleanfalse
onOpenChange({ open }: OpenChangeDetails) => void-
modalbooleantrue
closeOnEscapebooleantrue
closeOnInteractOutsidebooleantrue
initialFocusEl() => MaybeElement-
finalFocusEl() => MaybeElement-
onEscapeKeyDown(event: KeyboardEvent) => void-
onInteractOutside(event: InteractOutsideEvent) => void-
classNamestring-

SheetTrigger#

Opens the sheet on click. Use asChild for custom triggers.

PropTypeDefault
asChildbooleanfalse
classNamestring-

SheetContent#

Holds the sheet panel. Slides in from the configured edge.

PropTypeDefault
side`"right""left"
variant`"default""inset"`
showCloseButtonbooleantrue
classNamestring-
AttributeDefault
--space--spacing(6)

SheetHeader#

Header area for title and description.

PropTypeDefault
titlestring-
descriptionstring-
classNamestring-

SheetBody#

Scrollable body content. Uses ScrollArea for overflow.

PropTypeDefault
scrollFadebooleanfalse
classNamestring-

SheetFooter#

Footer area for action buttons.

PropTypeDefault
classNamestring-

SheetTitle#

Accessible title. Announced to screen readers.

PropTypeDefault
asChildbooleanfalse
classNamestring-

SheetDescription#

Accessible description. Announced to screen readers.

PropTypeDefault
asChildbooleanfalse
classNamestring-

SheetClose#

Closes the sheet on click.

PropTypeDefault
asChildbooleanfalse
classNamestring-

SheetOverlay#

Dimmed overlay behind the sheet.

PropTypeDefault
classNamestring-

SheetPositioner#

Positioning wrapper for sheet content. Used internally; expose for custom layouts.

PropTypeDefault
side`"right""left"
variant`"default""inset"`
classNamestring-

For a complete list of props, see the Ark UI documentation.

[

Previous page

Separator ](/docs/components/separator)[

Next page

Sidebar ](/docs/components/sidebar)

On This Page

InstallationAnatomyUsageControlledSidesExamplesInset VariantScrollableNo Close ButtonClose behaviorNon-ModalCustom spacingAPI ReferenceSheetSheetTriggerSheetContentSheetHeaderSheetBodySheetFooterSheetTitleSheetDescriptionSheetCloseSheetOverlaySheetPositioner