Sheet

A dialog that slides in from an edge of the screen and holds content related to the page.

import { Button } from "@/components/ui/button"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import {
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@/components/ui/sheet"
import { VStack } from "@/components/ui/stack"

export default function SheetDemo() {
  return (
    <Sheet>
      <SheetTrigger render={<Button variant="outline" />}>Open</SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Profile</SheetTitle>
          <SheetDescription>Update your name and username, then save.</SheetDescription>
        </SheetHeader>
        <VStack grow paddingInline={4}>
          <FieldGroup gap={6}>
            <Field>
              <FieldLabel>Name</FieldLabel>
              <Input id="sheet-demo-name" defaultValue="Ada Lovelace" />
            </Field>
            <Field>
              <FieldLabel>Username</FieldLabel>
              <Input id="sheet-demo-username" defaultValue="@lovelace" />
            </Field>
          </FieldGroup>
        </VStack>
        <SheetFooter>
          <Button type="submit">Save changes</Button>
          <SheetClose render={<Button variant="outline" />}>Close</SheetClose>
        </SheetFooter>
      </SheetContent>
    </Sheet>
  )
}

Installation

pnpm dlx shadcn@latest add @arene/sheet

Needs the arene setup first. Also adds Button.

Usage

import {
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@/components/ui/sheet"
<Sheet>
  <SheetTrigger render={<Button variant="outline" />}>Open</SheetTrigger>
  <SheetContent>
    <SheetHeader>
      <SheetTitle>Profile</SheetTitle>
      <SheetDescription>Update your name and username, then save.</SheetDescription>
    </SheetHeader>
  </SheetContent>
</Sheet>

Composition

Sheet
├── SheetTrigger
└── SheetContent          portal + overlay + popup
    ├── SheetHeader
    │   ├── SheetTitle
    │   └── SheetDescription
    └── SheetFooter
        └── SheetClose

SheetContent renders the portal, the overlay and the popup in one part. Reach the overlay through overlayProps, or compose SheetPortal and SheetOverlay yourself.

SheetHeader and SheetFooter carry their own padding, and the popup spaces its children with a gap. A body between them needs only inline padding, so give it a VStack with paddingInline={4}.

Side

Set side on SheetContent to choose the edge the sheet slides in from: top, right, bottom or left.

import * as stylex from "@stylexjs/stylex"
import { Button } from "@/components/ui/button"
import {
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@/components/ui/sheet"
import { HStack, VStack } from "@/components/ui/stack"

const sides = ["top", "right", "bottom", "left"] as const

const styles = stylex.create({
  short: { maxHeight: "50vh" },
})

export default function SheetSide() {
  return (
    <HStack gap={2} wrap="wrap" justify="center">
      {sides.map((side) => (
        <Sheet key={side}>
          <SheetTrigger render={<Button variant="outline" />}>{side}</SheetTrigger>
          <SheetContent
            side={side}
            xstyle={side === "top" || side === "bottom" ? styles.short : undefined}
          >
            <SheetHeader>
              <SheetTitle>Profile</SheetTitle>
              <SheetDescription>Update your name and username, then save.</SheetDescription>
            </SheetHeader>
            <VStack grow scrollable gap={2} paddingInline={4} className="no-scrollbar">
              {Array.from({ length: 10 }).map((_, index) => (
                <p key={index}>
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
                  incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
                  exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
                  irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
                  pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
                  officia deserunt mollit anim id est laborum.
                </p>
              ))}
            </VStack>
            <SheetFooter>
              <Button type="submit">Save changes</Button>
              <SheetClose render={<Button variant="outline" />}>Cancel</SheetClose>
            </SheetFooter>
          </SheetContent>
        </Sheet>
      ))}
    </HStack>
  )
}

A side sheet is 75% of the viewport width, or 24rem from 48rem up. A top or bottom sheet is the height of its content. Cap it with maxHeight through xstyle, and make the body a flex child with grow and overflow-y: auto. VStack's scrollable sets both.

No close button

Pass showCloseButton={false} to SheetContent to leave out the corner button. Escape and a click outside still close the sheet.

import { Button } from "@/components/ui/button"
import {
  Sheet,
  SheetContent,
  SheetDescription,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@/components/ui/sheet"

export default function SheetNoCloseButton() {
  return (
    <Sheet>
      <SheetTrigger render={<Button variant="outline" />}>Open</SheetTrigger>
      <SheetContent showCloseButton={false}>
        <SheetHeader>
          <SheetTitle>Reading options</SheetTitle>
          <SheetDescription>
            There is no close button in the corner. Press Escape or click outside the sheet to close
            it.
          </SheetDescription>
        </SheetHeader>
      </SheetContent>
    </Sheet>
  )
}

API reference

Pass render to replace a part's element or compose it with another component.

Every part wraps the Base UI Dialog part of the same name and accepts its props. See the Base UI reference for the full list. Each styled part also takes xstyle and className.

Sheet

PropTypeDefault
openboolean—
defaultOpenbooleanfalse
onOpenChange(open: boolean, details) => void—
modalboolean | "trap-focus"true
disablePointerDismissalbooleanfalse

SheetContent

PropTypeDefault
side"top" | "right" | "bottom" | "left""right"
showCloseButtonbooleantrue
overlayPropsSheetOverlayProps—
initialFocusboolean | RefObject | (type) => …—
finalFocusboolean | RefObject | (type) => …—

sheetStyles

The style map behind SheetContent, exported so the same box can be put on another element.

KeyDescription
contentThe fixed panel: the shared surface, shadow and transition
sidesOne style per side, with the edge, size and closed offset

content is a pair: states.popupSurface from theme/states.ts and the panel's own box over it. The panel takes the surface's shadow a level deeper, as the dialog does. There is no border. The shadow's hairline ring draws the edge that faces the page, and the other three sides sit past the viewport.

Data attributes

AttributeOnEffect
data-slot="sheet-content"the popupPopup slot
data-slot="sheet-overlay"the scrimBackdrop surface
data-sidethe popupThe side prop, "right" by default
data-starting-style, data-ending-stylepopup and overlayBase UI writes them while the sheet animates
data-open, data-closedpopup and overlayBase UI writes them