Skip to content

    Sheet

    A dialog that slides in from an edge of the screen and runs along it: details of a row, filters, settings, a form next to the page it changes. It shares Dialog's scrim, raised surface and close button; only the side that faces the content has a border and page corners.

    React

    Preview

    Props

    • open
    • defaultOpen
    • side
    • size
    • showCloseButton
    • swipeToDismiss
    • title
    import { Button } from "@/components/ui/button"
    import { Field, FieldControl, FieldLabel } from "@/components/ui/field"
    import { Input } from "@/components/ui/input"
    import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
    
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>

    Usage

    When to use

    • Work in a side panel next to the page: the details of a row, filters, a short form, a file upload.
    • Navigation on a narrow screen, from the start edge, or a few choices on a phone, from the bottom.

    When not to use

    • Confirming an action that destroys data. Use AlertDialog.
    • A focused task that stands on its own, such as renaming a project. Use Dialog.
    • A menu of actions. Use DropdownMenu.

    Platform support

    What each platform has, from the spec. A selected platform is highlighted.

    NameWebiOSAndroidNote
    openYesYesYesOnly on web, iOS, Android.
    defaultOpenYesYesYesOnly on web, iOS, Android.
    onOpenChangeYesYesYesOnly on web, iOS, Android.
    titleNoYesYesOnly on iOS, Android.
    descriptionNoYesYesOnly on iOS, Android.
    footerNoYesYesOnly on iOS, Android.
    sideYesYesYesDeferred on iOS and Android: top, right, left.
    value of side: topYesDeferredDeferred
    value of side: rightYesDeferredDeferred
    value of side: leftYesDeferredDeferred
    sizeYesYesYes
    showCloseButtonYesNoNoOnly on web. Not generated for iOS and Android.
    swipeToDismissYesYesYes
    handleLabelNoYesYesOnly on iOS, Android.

    Variants

    side

    Set on SheetContent. The edge it slides in from. right for details and forms next to a list; left for navigation; bottom for short choices on a phone; top rarely.

    • top

    • rightdefault

    • bottom

    • left

    import { Button } from "@/components/ui/button"
    import { Field, FieldControl, FieldLabel } from "@/components/ui/field"
    import { Input } from "@/components/ui/input"
    import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
    
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent side="top">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent side="bottom">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent side="left">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>

    size

    Set on SheetContent. Widest it gets on the left and right (sm 320px, md 448px, lg 672px), tallest on the top and bottom (a third, half, three quarters of the screen). full covers the screen along that side, with no corners.

    • sm

    • mddefault

    • lg

    • full

    import { Button } from "@/components/ui/button"
    import { Field, FieldControl, FieldLabel } from "@/components/ui/field"
    import { Input } from "@/components/ui/input"
    import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
    
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent size="sm">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent size="lg">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent size="full">
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>

    Examples

    Edit details

    import { Button } from "@/components/ui/button"
    import { Field, FieldControl, FieldLabel } from "@/components/ui/field"
    import { Input } from "@/components/ui/input"
    import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
    
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Edit project</Button>
      </SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Edit project</SheetTitle>
          <SheetDescription>Changes are visible to everyone on your team.</SheetDescription>
        </SheetHeader>
        <Field>
          <FieldLabel>Name</FieldLabel>
          <FieldControl>
            <Input defaultValue="Werewolf" />
          </FieldControl>
        </Field>
        <SheetFooter>
          <SheetClose asChild>
            <Button variant="secondary">Cancel</Button>
          </SheetClose>
          <Button>Save</Button>
        </SheetFooter>
      </SheetContent>
    </Sheet>

    From the bottom

    Short choices on a phone, with the main action one tap away. Like the iOS system sheet it has a drag handle: swipe it down to close.

    import { Button } from "@/components/ui/button"
    import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
    import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"
    
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="secondary">Sort</Button>
      </SheetTrigger>
      <SheetContent side="bottom" size="sm">
        <SheetHeader>
          <SheetTitle>Sort projects</SheetTitle>
        </SheetHeader>
        <RadioGroup aria-label="Sort projects" defaultValue="recent">
          <RadioGroupItem value="recent" label="Recently edited" />
          <RadioGroupItem value="name" label="Name" />
        </RadioGroup>
      </SheetContent>
    </Sheet>

    Do and don't

    Do

    • Use it for work next to the page: the details of a row, filters, a short form.
    • Give it a title, and put the main action in the footer.
    • Keep it open while the user works in it; close it when the action is done.

    Don't

    • Don't use it for a short confirmation; use AlertDialog or Dialog.
    • Don't open a sheet from a sheet.
    • Don't use it for a menu of actions; use DropdownMenu.

    Props

    NameTypeValuesDefaultDescription
    openboolean--Set on Sheet. Whether it is open, when you control it. Pair it with onOpenChange. Native: isPresented (SwiftUI Binding) or open (Compose). Only on web, iOS, Android.
    defaultOpenboolean-falseSet on Sheet. Opens it on first render, when you don't control it. Only on web, iOS, Android.
    onOpenChangefunction--Set on Sheet. Called with true or false when it opens or closes (trigger, close button, Escape, scrim). Native: called with false when the handle's accessibility action, a swipe, the scrim or the system back action closes it. Only on web, iOS, Android.
    title requiredstring--The name of the sheet, drawn as its title and read by assistive technology (the native SheetTitle). Required: a sheet without a name does not compile. Only on iOS, Android.
    descriptionnode--Optional supporting text under the title. Only on iOS, Android.
    footernode--Actions at the end of the sheet. Only on iOS, Android.
    sideenumtop | right | bottom | leftrightSet on SheetContent. The edge it slides in from. right for details and forms next to a list; left for navigation; bottom for short choices on a phone; top rarely. Deferred on iOS and Android: top, right, left.
    sizeenumsm | md | lg | fullmdSet on SheetContent. Widest it gets on the left and right (sm 320px, md 448px, lg 672px), tallest on the top and bottom (a third, half, three quarters of the screen). full covers the screen along that side, with no corners.
    showCloseButtonboolean-trueSet on SheetContent. The corner close button. Hide it only when the footer has a Cancel or Close. Only on web. Not generated for iOS and Android.
    swipeToDismissboolean-trueside bottom only (ignored on other sides): drag the sheet down to close it. Start on the handle or header always, on the body only when it is scrolled to the top. Dragging up gives resistance and never grows the sheet. Release closes when the drag passes 25 percent of the sheet height or 80px, or the release speed is at least 0.5 px/ms downward; otherwise it settles back: on the web on the spring (duration-spring, ease-spring), on native with duration-medium and ease-standard. The scrim fades with the offset. Closing finishes on the web with animate-exit-spring-bottom, from where the finger left the panel, and calls onOpenChange(false) once, so focus returns to the trigger like Escape. Under reduced motion the sheet still follows the finger, but it jumps back without moving and the exit fades. Escape, the close button and the scrim keep working. Drags that start on a field, a slider or anything marked data-sheet-swipe-ignore stay with that control. On by default, like the iOS system sheet; it also shows the drag handle.
    handleLabelstring-CloseNative only. The accessible name of the drag handle, whose accessibility action closes the sheet, because the native Sheet has no corner close button. Default EN `Close`, VI `Đóng`. A tap on the handle never closes the sheet, like the iOS grabber. The web handle is decorative, so the web SheetContent has no handleLabel: Escape, the corner close button and the scrim close it. Only on iOS, Android.

    Slots

    NameRequiredDescription
    triggernoSheetTrigger with asChild around a Button.
    titleyesSheetTitle, required for a11y.
    descriptionnoOptional SheetDescription.
    contentyesThe body: fields, details, a list. It scrolls with the panel.
    footernoSheetFooter with the actions.

    Anatomy

    PartDescription
    rootSheet. Holds the open state.
    overlayThe scrim behind the sheet, the same as Dialog's. Behind a bottom sheet it is color-overlay-scrim-sheet, the lighter dim of the iOS system sheet (web).
    contentThe panel: raised fill, shadow-high, p-xl, gap-lg. It covers the full length of its side; the border and the page corners are only on the side that faces the content.
    headerTop block for the title and description, gap-sm.
    titleThe name of the sheet: 16px medium.
    descriptionOptional supporting text: 14px secondary.
    footerActions at the end of the panel, however short the content is.
    closeIcon button in the corner that closes the sheet, the same as Dialog's.
    iconTabler X in the close button, 16px.
    hitAreaTransparent ::before on the close button, never smaller than size-target-min.
    handleRowThe row that centers the drag handle above the title, side bottom with swipeToDismiss only. A drag can always start here.
    handleThe drag handle of a bottom sheet, like the grabber of the iOS system sheet: a small rounded bar that only signals the drag; a tap does not close the sheet. Its hit area is never smaller than size-target-min. Native: one accessibility element named by handleLabel whose action closes the sheet.

    Accessibility

    Role: dialog

    KeysAction
    EscapeCloses the sheet and returns focus to the trigger.
    TabCycles focus inside the sheet (focus trap).
    • A modal dialog: it traps focus, hides the rest of the page from assistive tech and closes on Escape or a scrim press.
    • Always provide a SheetTitle (visible or sr-only), so the sheet has a name.
    • The corner close is a button with a visually hidden Close label and a Tabler X. With showCloseButton={false}, the footer must have a Cancel or Close.
    • It slides in only when the user allows motion; under prefers-reduced-motion it fades in. On close it slides back out to the same edge, faster (duration-medium, ease-exit), or fades out.
    • A bottom sheet moves like the iOS system sheet: it presents, dismisses and settles back after a swipe on a critically damped spring (duration-spring, ease-spring, web only) and does not fade while it moves; its scrim is the lighter color-overlay-scrim-sheet and fades on the same spring. Under prefers-reduced-motion it fades in and out like the other sides.
    • Do not open a sheet from a sheet.
    • A bottom sheet stays above the on-screen keyboard on the web: it reads the visual viewport, sits on top of the keyboard, is never taller than the visible area, and scrolls a focused field into view (at once under reduced motion). Pinch zoom is not treated as a keyboard.
    • Bottom sheets pad their bottom by env(safe-area-inset-bottom), which needs viewport-fit=cover in the viewport meta and falls back to 0px. Swipe to dismiss is an extra path; keyboard and screen reader users close with Escape or the close button.
    • A bottom sheet follows the iOS system sheet: a drag handle at the top and a swipe down to close (swipeToDismiss, on by default). Like the iOS grabber, the handle is only a drag affordance: a tap does not close the sheet. On the web it is decorative (aria-hidden), and Escape, the corner close button and the scrim are the other ways to close. On native, where there is no corner close button, the handle is one accessibility element named by handleLabel whose action closes the sheet. With swipeToDismiss={false} there is no handle and no swipe.

    Install

    npx werewolf-ui add sheet

    Run npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.