Sheet

A panel that rises from an edge of the screen, floating clear of it, and leaves with a swipe.

'use client';

import { Button } from '@/components/panelui/button';
import { Field } from '@/components/panelui/field';
import { Label } from '@/components/panelui/label';
import { Radio, RadioGroup } from '@/components/panelui/radio-group';
import { Switch } from '@/components/panelui/switch';
import { Textarea } from '@/components/panelui/textarea';
import { Sheet } from '@/components/panelui/sheet';

export default function SheetEvent() {
  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>Respond to invite</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header
          title="Design critique"
          description="Thursday 22 October · 14:00–15:00"
        />
        <Sheet.Body className="flex flex-col gap-6">
          <RadioGroup defaultValue="going" aria-label="Your answer">
            <Label>
              <Radio value="going" />
              <Label.Text>Going</Label.Text>
            </Label>
            <Label>
              <Radio value="maybe" />
              <Label.Text>Maybe</Label.Text>
            </Label>
            <Label>
              <Radio value="declined" />
              <Label.Text>Can’t make it</Label.Text>
            </Label>
          </RadioGroup>
          <Field>
            <Field.Label>Note to Noor</Field.Label>
            <Textarea placeholder="Running ten minutes late, start without me." />
          </Field>
          <Label>
            <Label.Text>Remind me 15 minutes before</Label.Text>
            <Label.Action>
              <Switch defaultChecked />
            </Label.Action>
          </Label>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Send answer</Sheet.Close>
          <Sheet.Close render={<Button size="lg" variant="ghost" />}>Cancel</Sheet.Close>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  );
}

Use it for a task that belongs to the page but should not leave it: answering an invitation, editing a profile, changing a setting. It rises from an edge, stands a few pixels clear of every side with its corners rounded, and goes back with a swipe, the Escape key or a click outside.

A sheet that needs the whole height can meet the edges instead: set size="full" or detached={false}.

A sheet can open another. Declare the second one inside the first as Sheet.Next with a name, and any Sheet.Trigger to="name" in the first opens it: a row in the body, an icon in the header, a button in the footer. The first sheet steps back behind it. Wrap the app in Sheet.Stage and the page steps back too.

For a decision that needs an answer before anything else, use a dialog. For one question with a written answer, use Feedback.

Installation

npx shadcn@latest add https://panelui.dev/r/web/sheet.json

The source is copied into components/panelui/, where you can edit it.

Usage

import { Sheet } from "@/components/panelui/sheet"
<Sheet>
  <Sheet.Trigger render={<Button />}>Edit profile</Sheet.Trigger>
  <Sheet.Content>
    <Sheet.Header title="Edit profile" description="Shown on your public page." />
    <Sheet.Body>
      <Field>
        <FieldLabel>Name</FieldLabel>
        <Input defaultValue="Noor Haddad" />
      </Field>
    </Sheet.Body>
    <Sheet.Footer>
      <Sheet.Close render={<Button />}>Save changes</Sheet.Close>
      <Sheet.Close render={<Button variant="ghost" />}>Cancel</Sheet.Close>
    </Sheet.Footer>
  </Sheet.Content>
</Sheet>

Composition

<Sheet.Stage>
  <Sheet>
    <Sheet.Trigger />
    <Sheet.Content>
      <Sheet.Header>
        <Sheet.Close />
        <Sheet.Title />
        <Sheet.Description />
      </Sheet.Header>
      <Sheet.Body>
        <Sheet.Trigger to="details" />
      </Sheet.Body>
      <Sheet.Slides>
        <Sheet.Slide />
      </Sheet.Slides>
      <Sheet.Footer>
        <Sheet.Close />
      </Sheet.Footer>
      <Sheet.Next name="details">
        <Sheet.Header />
        <Sheet.Body />
        <Sheet.Footer />
      </Sheet.Next>
    </Sheet.Content>
  </Sheet>
</Sheet.Stage>
  • Sheet.Trigger — What opens a sheet. A plain button, or your own through render. With to, it opens the Sheet.Next of that name instead, and payload is handed to that sheet.
  • Sheet.Content — The sheet and the backdrop behind it. It draws the grabber on a top or bottom sheet and the round close button in the top trailing corner. showGrabber={false} and showClose={false} leave them out. inline draws it in the page instead of over it.
  • Sheet.Next — A second sheet, opened from the first by any Sheet.Trigger whose to is its name. Declare it anywhere inside the first sheet's content. It takes the same props as Content and draws its own, so its children are the header, body and footer. Pass a function as its children to read the opening trigger's payload.
  • Sheet.Header — The title and a line under it, as title and description or as Title and Description children. It leaves room for the close button on the same line.
  • Sheet.Title — The sheet's name. It is also what a screen reader announces when the sheet opens.
  • Sheet.Description — A sentence under the title, read out after it.
  • Sheet.Body — The part that scrolls. The header and footer stay where they are while it moves.
  • Sheet.Slides — A column of rounded slides in place of Sheet.Body, for photos or a deck. By default it is a deck: each slide fills the sheet's height, a scroll glides to the next slide, the arrow keys move one at a time, and a counter sits under it. snap={false} makes it a numbered column of smaller slides that scrolls freely, and with onIndexChange pressing one chooses it. index and defaultIndex hold the current slide.
  • Sheet.Slide — One slide: a rounded frame that an image or a video fills edge to edge, or anything drawn. label is what a screen reader calls it after its place, such as "3 of 8".
  • Sheet.Footer — The actions, stacked full width.
  • Sheet.Close — Closes the sheet, even when dismissible is off. Give it render or children to make your own button close it. Written with nothing inside, it is the round close button, drawn where it is written; the one in the corner is then left out. Inside Sheet.Header it shares the title's line, before the title or after it depending on where it is written.
  • Sheet.Stage — Wraps the page. While a sheet inside it is open, the page steps back slightly and rounds its corners. Set --stage-radius to the radius of what it sits in, less the gap, so the two corners are concentric.

Examples

From any edge

side sets the edge the sheet rises from and is swiped back to. Side sheets run the full height, still clear of the edges.

'use client';

import { Button } from '@/components/panelui/button';
import { Sheet, type SheetSide } from '@/components/panelui/sheet';

const SIDES: SheetSide[] = ['top', 'right', 'bottom', 'left'];

export default function SheetSides() {
  return (
    <div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
      {SIDES.map((side) => (
        <Sheet key={side} side={side}>
          <Sheet.Trigger render={<Button variant="outline" className="capitalize" />}>{side}</Sheet.Trigger>
          <Sheet.Content>
            <Sheet.Header
              title="Edit profile"
              description="Make changes to your profile here. Save when you are done."
            />
            <Sheet.Body />
            <Sheet.Footer>
              <Sheet.Close render={<Button size="lg" />}>Save changes</Sheet.Close>
            </Sheet.Footer>
          </Sheet.Content>
        </Sheet>
      ))}
    </div>
  );
}

Text you can copy

With a mouse, the title, description, body and footer are for reading: a double-click selects a word and a drag selects a line, the same as on the page. Drag the sheet by its grabber or the space around the header. On a touch screen a finger still swipes the sheet from anywhere.

'use client';

import { CheckIcon, CopyIcon } from 'lucide-react';
import { useState } from 'react';
import { Button } from '@/components/panelui/button';
import { Sheet } from '@/components/panelui/sheet';

const CODES = ['7KQ2-M9XD', 'HV4T-28PL', 'Q0RS-6WNE', 'ZB3J-T1YC', 'LM8F-UA5K', 'D6GX-4PEQ', 'W2NH-9VRB', 'C5YT-KJ70'];

export default function SheetCopy() {
  const [copied, setCopied] = useState(false);
  const copy = async () => {
    try {
      await navigator.clipboard.writeText(CODES.join('\n'));
      setCopied(true);
      window.setTimeout(() => setCopied(false), 1600);
    } catch {
      // The codes can still be selected and copied by hand.
    }
  };

  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>Show recovery codes</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header
          title="Recovery codes"
          description="Each code signs you in once if you lose your phone. Keep them somewhere other than this computer."
        />
        <Sheet.Body>
          <ol className="grid grid-cols-2 gap-x-6 gap-y-2.5 rounded-2xl bg-muted px-5 py-4 font-mono text-[15px] tabular-nums">
            {CODES.map((code, at) => (
              <li key={code} className="flex items-baseline gap-3">
                <span className="w-4 text-end text-xs text-muted-foreground select-none">{at + 1}</span>
                {code}
              </li>
            ))}
          </ol>
          <p className="mt-3 text-sm text-muted-foreground">
            Generated 26 October. Making new codes turns these off.
          </p>
        </Sheet.Body>
        <Sheet.Footer>
          <Button size="lg" onClick={copy}>
            {copied ? <CheckIcon /> : <CopyIcon />}
            {copied ? 'Copied' : 'Copy all eight'}
          </Button>
          <Sheet.Close render={<Button size="lg" variant="ghost" />}>Done</Sheet.Close>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  );
}

Your own close button

Write a bare <Sheet.Close /> where the close button should go. Here it is first in Sheet.Header, so it stands before the title on the same line, and the sheet leaves its corner empty.

'use client';

import { Button } from '@/components/panelui/button';
import { Sheet } from '@/components/panelui/sheet';

const GROUPS = [
  { label: 'Orientation', options: ['Any', 'Landscape', 'Portrait', 'Square'] },
  { label: 'Taken', options: ['Any time', 'This week', 'This month', 'This year'] },
  { label: 'Camera', options: ['Any', 'Phone', 'Mirrorless', 'Film scan'] },
];

export default function SheetOwnClose() {
  return (
    <Sheet side="left">
      <Sheet.Trigger render={<Button variant="outline" />}>Filter photos</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header>
          {/* Written first, so it stands before the title instead of in the corner. */}
          <Sheet.Close />
          <Sheet.Title>Filters</Sheet.Title>
          <Sheet.Description>1,284 photos match</Sheet.Description>
        </Sheet.Header>
        <Sheet.Body className="flex flex-col gap-6 pt-2">
          {GROUPS.map((group) => (
            <fieldset key={group.label} className="flex flex-col gap-2.5">
              <legend className="mb-2.5 text-sm font-medium">{group.label}</legend>
              <div className="flex flex-wrap gap-2">
                {group.options.map((option, at) => (
                  <label
                    key={option}
                    className="cursor-pointer rounded-full bg-muted px-3.5 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground has-checked:bg-foreground has-checked:text-background"
                  >
                    <input type="radio" name={group.label} defaultChecked={at === 0} className="sr-only" />
                    {option}
                  </label>
                ))}
              </div>
            </fieldset>
          ))}
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Show 1,284 photos</Sheet.Close>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  );
}

Without a close button

showClose={false} removes the close button. With dismissible={false} as well, the only way out is a Sheet.Close in the footer, which suits a sheet that needs an answer before the task can go on.

'use client';

import { MicIcon, MonitorIcon, MousePointer2Icon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Sheet } from '@/components/panelui/sheet';

const CAPTURED = [
  { icon: MonitorIcon, title: 'The window you choose', detail: 'Nothing outside it is recorded.' },
  { icon: MicIcon, title: 'Your microphone', detail: 'Only while the red dot shows.' },
  { icon: MousePointer2Icon, title: 'Pointer and clicks', detail: 'So the edit can zoom where you click.' },
];

export default function SheetNoClose() {
  return (
    <Sheet dismissible={false}>
      <Sheet.Trigger render={<Button variant="outline" />}>Start recording</Sheet.Trigger>
      {/* No close button, no swipe, no click outside: the footer is the only way out. */}
      <Sheet.Content showClose={false}>
        <Sheet.Header title="Before you record" description="This recording keeps three things." />
        <Sheet.Body>
          <ul className="flex flex-col gap-4">
            {CAPTURED.map(({ icon: Icon, title, detail }) => (
              <li key={title} className="flex items-start gap-3.5">
                <span className="flex size-9 shrink-0 items-center justify-center rounded-xl bg-muted">
                  <Icon className="size-4.5" />
                </span>
                <span className="flex flex-col">
                  <span className="text-[15px] font-medium">{title}</span>
                  <span className="text-sm text-muted-foreground">{detail}</span>
                </span>
              </li>
            ))}
          </ul>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Allow and record</Sheet.Close>
          <Sheet.Close render={<Button size="lg" variant="ghost" />}>Not now</Sheet.Close>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  );
}

Photos, one at a time

Sheet.Slides in a size="full" sheet is a deck of rounded slides, each as tall as the sheet. A turn of the wheel or a swipe of the trackpad glides to the next photo, however hard it is, and on a touch screen the photo follows the finger and settles. The arrow keys move one at a time, and the counter under it says which one is showing.

'use client';

import { ImagesIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Sheet } from '@/components/panelui/sheet';

const PHOTO = (id: string) => `https://images.unsplash.com/photo-${id}?auto=format&fit=crop&w=900&q=70`;

const PHOTOS = [
  { id: '1506905925346-21bda4d32df4', alt: 'Snowy peaks above a sea of cloud at dusk' },
  { id: '1470071459604-3b5ec3a7fe05', alt: 'Green cliffs under morning cloud' },
  { id: '1441974231531-c6227db76b6e', alt: 'A path through a sunlit forest' },
  { id: '1493246507139-91e8fad9978e', alt: 'Mountains reflected in a still turquoise lake' },
  { id: '1507525428034-b723cf961d3e', alt: 'Waves reaching a beach at sunrise' },
  { id: '1519681393784-d120267933ba', alt: 'The night sky over a snowy ridge' },
  { id: '1472214103451-9374bd1c798e', alt: 'Green hills at sunset' },
];

export default function SheetSlidesPhotos() {
  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>
        <ImagesIcon />
        View the album
      </Sheet.Trigger>
      <Sheet.Content size="full">
        <Sheet.Header title="Highlands" description={`${PHOTOS.length} photos from the trip`} />
        <Sheet.Slides aria-label="Photos">
          {PHOTOS.map((photo) => (
            <Sheet.Slide key={photo.id}>
              <img src={PHOTO(photo.id)} alt={photo.alt} decoding="async" draggable={false} />
            </Sheet.Slide>
          ))}
        </Sheet.Slides>
      </Sheet.Content>
    </Sheet>
  );
}

A deck in a column

With snap={false} the slides become a numbered column that scrolls freely, like a presentation's slide panel. Given onIndexChange, each slide is a button: pressing one chooses it and rings it in the info colour, and the arrow keys move the choice. index holds the choice outside, to show the slide wherever the page needs it.

'use client';

import { PanelLeftIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Sheet } from '@/components/panelui/sheet';
import { useState } from 'react';

type Slide =
  | { kind: 'title'; title: string; byline: string }
  | { kind: 'bars'; title: string; bars: [string, number][] }
  | { kind: 'list'; title: string; items: string[] }
  | { kind: 'figure'; title: string; value: string; note: string }
  | { kind: 'columns'; title: string; columns: [string, string][] }
  | { kind: 'end'; title: string };

const SLIDES: Slide[] = [
  { kind: 'title', title: 'Q3 review', byline: 'Harbour team · October' },
  { kind: 'bars', title: 'Bookings by month', bars: [['Jul', 0.55], ['Aug', 0.72], ['Sep', 0.94]] },
  { kind: 'list', title: 'What shipped', items: ['Shared calendars', 'Offline check-in', 'Faster search'] },
  { kind: 'figure', title: 'Guests who came back', value: '68%', note: 'up from 61% in Q2' },
  { kind: 'columns', title: 'Next quarter', columns: [['Billing', 'Split payments'], ['Mobile', 'Boarding passes'], ['Ops', 'Night shifts']] },
  { kind: 'end', title: 'Questions?' },
];

const CHART = ['var(--chart-1)', 'var(--chart-2)', 'var(--chart-3)'];

/** One slide, drawn in units of its own width, so it reads at whatever size the column gives it. */
function SlideArt({ slide }: { slide: Slide }) {
  return (
    // The outer box is the container the drawing's units are measured against.
    <div className="size-full bg-card text-card-foreground [container-type:inline-size]">
      <div className="flex size-full flex-col p-[6cqw]">
      {slide.kind === 'title' ? (
        <div className="my-auto flex flex-col gap-[2cqw]">
          <div className="h-[1.2cqw] w-[12cqw] rounded-full bg-primary" />
          <p className="text-[9cqw] font-semibold leading-none tracking-tight">{slide.title}</p>
          <p className="text-[3.4cqw] text-muted-foreground">{slide.byline}</p>
        </div>
      ) : slide.kind === 'end' ? (
        <p className="m-auto text-[8cqw] font-semibold tracking-tight">{slide.title}</p>
      ) : (
        <>
          <p className="text-[4.6cqw] font-semibold leading-tight">{slide.title}</p>
          {slide.kind === 'bars' ? (
            <div className="mt-auto flex h-[30cqw] items-end gap-[4cqw]">
              {slide.bars.map(([month, value], at) => (
                <div key={month} className="flex h-full flex-1 flex-col items-center justify-end gap-[1.5cqw]">
                  <div className="w-full rounded-[1.4cqw]" style={{ height: `${value * 100}%`, background: CHART[at] }} />
                  <span className="text-[2.6cqw] text-muted-foreground">{month}</span>
                </div>
              ))}
            </div>
          ) : null}
          {slide.kind === 'list' ? (
            <ul className="mt-[5cqw] flex flex-col gap-[3cqw]">
              {slide.items.map((item, at) => (
                <li key={item} className="flex items-center gap-[2.5cqw] text-[3.6cqw]">
                  <span className="size-[2cqw] shrink-0 rounded-full" style={{ background: CHART[at] }} />
                  {item}
                </li>
              ))}
            </ul>
          ) : null}
          {slide.kind === 'figure' ? (
            <div className="my-auto flex flex-col gap-[1cqw]">
              <p className="text-[16cqw] font-semibold leading-none tracking-tight" style={{ color: 'var(--chart-2)' }}>
                {slide.value}
              </p>
              <p className="text-[3.2cqw] text-muted-foreground">{slide.note}</p>
            </div>
          ) : null}
          {slide.kind === 'columns' ? (
            <div className="mt-auto grid grid-cols-3 gap-[3cqw]">
              {slide.columns.map(([area, plan], at) => (
                <div key={area} className="flex flex-col gap-[1.2cqw] rounded-[2cqw] bg-muted p-[3cqw]">
                  <span className="h-[1cqw] w-[6cqw] rounded-full" style={{ background: CHART[at] }} />
                  <span className="text-[3.2cqw] font-medium">{area}</span>
                  <span className="text-[2.6cqw] text-muted-foreground">{plan}</span>
                </div>
              ))}
            </div>
          ) : null}
        </>
      )}
      </div>
    </div>
  );
}

export default function SheetSlideColumn() {
  const [current, setCurrent] = useState(0);

  return (
    <Sheet side="left">
      <Sheet.Trigger render={<Button variant="outline" />}>
        <PanelLeftIcon />
        Slides
      </Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header title="Q3 review" description={`${SLIDES.length} slides`} />
        <Sheet.Slides snap={false} index={current} onIndexChange={setCurrent}>
          {SLIDES.map((slide) => (
            <Sheet.Slide key={slide.title} label={slide.title}>
              <SlideArt slide={slide} />
            </Sheet.Slide>
          ))}
        </Sheet.Slides>
      </Sheet.Content>
    </Sheet>
  );
}

A sheet from a sheet

Declare the second sheet as Sheet.Next inside the first, and give a Sheet.Trigger in the first its name as to. The trigger can be anything in the sheet. Here it is each row of a list, made pressable by render. The second sheet slides over from the same edge, and the first one steps back: a little smaller, pushed inward, and faded. Only the first sheet darkens the page.

'use client';

import { ImageIcon, LogOutIcon, UsersRoundIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Field } from '@/components/panelui/field';
import { Input } from '@/components/panelui/input';
import { Label } from '@/components/panelui/label';
import { Switch } from '@/components/panelui/switch';
import { Frame } from '@/components/panelui/frame';
import { Sheet } from '@/components/panelui/sheet';

const PEOPLE = [
  { name: 'Noor Haddad', role: 'Owner' },
  { name: 'Tomás Ferreira', role: 'Can add photos' },
  { name: 'Aiko Mori', role: 'Can add photos' },
  { name: 'Kwame Asante', role: 'Can view' },
  { name: 'Lena Vogt', role: 'Can view' },
];

// Stand-ins for six photos from the album.
const COVERS = [
  'from-chart-1 to-chart-4',
  'from-chart-2 to-chart-3',
  'from-chart-3 to-chart-1',
  'from-chart-4 to-chart-5',
  'from-chart-5 to-chart-2',
  'from-muted-foreground/50 to-chart-3',
];

export default function SheetNested() {
  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>Album settings</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header title="Album settings" description="Shared with five people · 214 photos" />
        <Sheet.Body className="flex flex-col gap-6">
          <Field>
            <Field.Label>Name</Field.Label>
            <Input defaultValue="Porto, May" />
          </Field>
          <Label>
            <Label.Text>Let others add photos</Label.Text>
            <Label.Action>
              <Switch defaultChecked />
            </Label.Action>
          </Label>
          {/* Each row opens a sheet of its own. They sit wherever the layout wants them. */}
          <Frame variant="plain">
            <Frame.Panel>
              <Sheet.Trigger to="people" render={<Frame.Row chevron />}>
                <Frame.Media className="text-muted-foreground">
                  <UsersRoundIcon className="size-4" />
                </Frame.Media>
                <Frame.Content>
                  <Frame.Title as="p">People</Frame.Title>
                </Frame.Content>
                <Frame.Actions className="text-sm text-muted-foreground">5</Frame.Actions>
              </Sheet.Trigger>
              <Sheet.Trigger to="cover" render={<Frame.Row chevron />}>
                <Frame.Media className="text-muted-foreground">
                  <ImageIcon className="size-4" />
                </Frame.Media>
                <Frame.Content>
                  <Frame.Title as="p">Cover photo</Frame.Title>
                </Frame.Content>
              </Sheet.Trigger>
            </Frame.Panel>
          </Frame>
          <Sheet.Trigger to="leave" render={<Button variant="destructive" />}>
            <LogOutIcon />
            Leave album
          </Sheet.Trigger>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Done</Sheet.Close>
        </Sheet.Footer>

        <Sheet.Next name="people">
          <Sheet.Header title="People" description="Everyone the album is shared with." />
          <Sheet.Body>
            <Frame variant="plain">
              <Frame.Panel>
                {PEOPLE.map((person) => (
                  <Frame.Row key={person.name}>
                    <Frame.Content>
                      <Frame.Title as="p">{person.name}</Frame.Title>
                      <Frame.Description>{person.role}</Frame.Description>
                    </Frame.Content>
                  </Frame.Row>
                ))}
              </Frame.Panel>
            </Frame>
          </Sheet.Body>
          <Sheet.Footer>
            <Sheet.Close render={<Button size="lg" />}>Done</Sheet.Close>
          </Sheet.Footer>
        </Sheet.Next>

        <Sheet.Next name="cover">
          <Sheet.Header title="Cover photo" description="Shown on the album in everyone’s library." />
          <Sheet.Body>
            <div className="grid grid-cols-3 gap-2">
              {COVERS.map((tone, index) => (
                <Sheet.Close
                  key={tone}
                  render={
                    <button
                      type="button"
                      aria-label={`Photo ${index + 1}`}
                      className={`aspect-square cursor-pointer rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ring bg-linear-to-br ${tone}`}
                    />
                  }
                />
              ))}
            </div>
          </Sheet.Body>
          <Sheet.Footer />
        </Sheet.Next>

        <Sheet.Next name="leave">
          <Sheet.Header
            title="Leave “Porto, May”?"
            description="The photos you added stay in the album. Anyone in it can invite you back."
          />
          <Sheet.Footer>
            <Sheet.Close render={<Button size="lg" variant="destructive" />}>Leave album</Sheet.Close>
            <Sheet.Close render={<Button size="lg" variant="ghost" />}>Stay</Sheet.Close>
          </Sheet.Footer>
        </Sheet.Next>
      </Sheet.Content>
    </Sheet>
  );
}

One sheet for every row

A trigger's payload reaches the Sheet.Next it opens. Give the sheet a function as its children and it is called with the payload, so one declaration serves every row of a list.

'use client';

import { PhoneIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Frame } from '@/components/panelui/frame';
import { Sheet } from '@/components/panelui/sheet';

interface Engineer {
  name: string;
  shift: string;
  area: string;
  phone: string;
}

const ROTA: Engineer[] = [
  { name: 'Ifeoma Okafor', shift: 'Mon–Tue · 08:00–20:00', area: 'Payments API', phone: '+44 20 7946 0112' },
  { name: 'Mateo Rossi', shift: 'Wed–Thu · 08:00–20:00', area: 'Search', phone: '+44 20 7946 0347' },
  { name: 'Hana Sato', shift: 'Fri–Sat · 20:00–08:00', area: 'Storage', phone: '+44 20 7946 0581' },
  { name: 'Samir Haddad', shift: 'Sun · all day', area: 'Edge network', phone: '+44 20 7946 0926' },
];

export default function SheetPayload() {
  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>On call this week</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header title="On call" description="19–25 October · four engineers" />
        <Sheet.Body>
          <Frame variant="plain">
            <Frame.Panel>
              {/* Every row opens the same sheet, filled with that row's engineer. */}
              {ROTA.map((engineer) => (
                <Sheet.Trigger key={engineer.name} to="engineer" payload={engineer} render={<Frame.Row chevron />}>
                  <Frame.Content>
                    <Frame.Title as="p">{engineer.name}</Frame.Title>
                    <Frame.Description>{engineer.shift}</Frame.Description>
                  </Frame.Content>
                </Sheet.Trigger>
              ))}
            </Frame.Panel>
          </Frame>
        </Sheet.Body>
        <Sheet.Footer />

        <Sheet.Next name="engineer">
          {(engineer: Engineer) => (
            <>
              <Sheet.Header title={engineer.name} description={engineer.area} />
              <Sheet.Body>
                <Frame variant="plain">
                  <Frame.Panel>
                    <Frame.Row>
                      <Frame.Content>
                        <Frame.Description>Shift</Frame.Description>
                        <Frame.Title as="p">{engineer.shift}</Frame.Title>
                      </Frame.Content>
                    </Frame.Row>
                    <Frame.Row>
                      <Frame.Content>
                        <Frame.Description>Phone</Frame.Description>
                        <Frame.Title as="p" className="tabular-nums">
                          {engineer.phone}
                        </Frame.Title>
                      </Frame.Content>
                      <Frame.Actions className="text-muted-foreground">
                        <PhoneIcon className="size-4" />
                      </Frame.Actions>
                    </Frame.Row>
                  </Frame.Panel>
                </Frame>
              </Sheet.Body>
              <Sheet.Footer>
                <Sheet.Close render={<Button size="lg" />}>Page {engineer.name.split(' ')[0]}</Sheet.Close>
                <Sheet.Close render={<Button size="lg" variant="ghost" />}>Ask to swap shifts</Sheet.Close>
              </Sheet.Footer>
            </>
          )}
        </Sheet.Next>
      </Sheet.Content>
    </Sheet>
  );
}

From the header

A trigger in the header, beside the title, for an action on the whole sheet's subject.

'use client';

import { FileTextIcon, UserPlusIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Field } from '@/components/panelui/field';
import { Input } from '@/components/panelui/input';
import { Frame } from '@/components/panelui/frame';
import { Sheet } from '@/components/panelui/sheet';

const DETAILS = [
  ['Size', '18.4 MB'],
  ['Pages', '42'],
  ['Uploaded', '14 October by Ruth Adeyemi'],
  ['Folder', 'Harbour Road / Surveys'],
];

export default function SheetHeaderTrigger() {
  return (
    <Sheet>
      <Sheet.Trigger render={<Button variant="outline" />}>File details</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header>
          <div className="flex items-center gap-3">
            <span className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground">
              <FileTextIcon className="size-5" />
            </span>
            <div className="min-w-0 flex-1">
              <Sheet.Title className="truncate">Site survey.pdf</Sheet.Title>
              <Sheet.Description>Only you can open it</Sheet.Description>
            </div>
            {/* A trigger in the header, beside the title. */}
            <Sheet.Trigger
              to="share"
              aria-label="Share"
              render={<Button size="icon" variant="outline" className="rounded-full" />}
            >
              <UserPlusIcon />
            </Sheet.Trigger>
          </div>
        </Sheet.Header>
        <Sheet.Body>
          <Frame variant="plain">
            <Frame.Panel>
              {DETAILS.map(([label, value]) => (
                <Frame.Row key={label}>
                  <Frame.Content>
                    <Frame.Description>{label}</Frame.Description>
                  </Frame.Content>
                  <Frame.Actions className="text-sm">{value}</Frame.Actions>
                </Frame.Row>
              ))}
            </Frame.Panel>
          </Frame>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Open</Sheet.Close>
        </Sheet.Footer>

        <Sheet.Next name="share">
          <Sheet.Header title="Share “Site survey.pdf”" description="People you add can open and comment." />
          <Sheet.Body>
            <Field>
              <Field.Label>Email</Field.Label>
              <Input type="email" placeholder="name@harbour.works" />
            </Field>
          </Sheet.Body>
          <Sheet.Footer>
            <Sheet.Close render={<Button size="lg" />}>Share</Sheet.Close>
          </Sheet.Footer>
        </Sheet.Next>
      </Sheet.Content>
    </Sheet>
  );
}

Three deep

A Sheet.Next can hold its own Sheet.Next. Here an item opens from the order, and removing it asks first, in a third sheet. Each sheet behind the front one steps back a little further.

'use client';

import { useState } from 'react';
import { Button } from '@/components/panelui/button';
import { Field } from '@/components/panelui/field';
import { Input } from '@/components/panelui/input';
import { Frame } from '@/components/panelui/frame';
import { Sheet } from '@/components/panelui/sheet';

interface Item {
  id: string;
  name: string;
  quantity: number;
  price: number;
}

const ITEMS: Item[] = [
  { id: 'oats', name: 'Rolled oats, 1 kg', quantity: 2, price: 3.4 },
  { id: 'figs', name: 'Dried figs', quantity: 1, price: 4.25 },
  { id: 'milk', name: 'Oat milk, 1 L', quantity: 4, price: 1.95 },
  { id: 'coffee', name: 'Coffee beans, 500 g', quantity: 1, price: 11.9 },
];

const money = (value: number) => `£${value.toFixed(2)}`;

export default function SheetDeep() {
  const [items, setItems] = useState(ITEMS);
  const total = items.reduce((sum, item) => sum + item.quantity * item.price, 0);

  return (
    <Sheet onOpenChange={(open) => open && setItems(ITEMS)}>
      <Sheet.Trigger render={<Button variant="outline" />}>Review order</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header title="Order 2841" description={`Delivery Saturday, 09:00–11:00 · ${money(total)}`} />
        <Sheet.Body>
          <Frame variant="plain">
            <Frame.Panel>
              {items.map((item) => (
                <Sheet.Trigger key={item.id} to="item" payload={item} render={<Frame.Row chevron />}>
                  <Frame.Content>
                    <Frame.Title as="p">{item.name}</Frame.Title>
                    <Frame.Description>
                      {item.quantity} × {money(item.price)}
                    </Frame.Description>
                  </Frame.Content>
                  <Frame.Actions className="text-sm tabular-nums">{money(item.quantity * item.price)}</Frame.Actions>
                </Sheet.Trigger>
              ))}
            </Frame.Panel>
          </Frame>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Place order</Sheet.Close>
        </Sheet.Footer>

        {/* The second sheet: one for every item. */}
        <Sheet.Next name="item">
          {(item: Item) => (
            <>
              <Sheet.Header title={item.name} description={`${money(item.price)} each`} />
              <Sheet.Body className="flex flex-col gap-4">
                <Field>
                  <Field.Label>Quantity</Field.Label>
                  <Input type="number" min={1} defaultValue={item.quantity} />
                </Field>
                <Field>
                  <Field.Label>Note for the picker</Field.Label>
                  <Input placeholder="A substitute is fine" />
                </Field>
              </Sheet.Body>
              <Sheet.Footer>
                <Sheet.Close render={<Button size="lg" />}>Save</Sheet.Close>
                <Sheet.Trigger to="remove" payload={item} render={<Button size="lg" variant="destructive" />}>
                  Remove from order
                </Sheet.Trigger>
              </Sheet.Footer>

              {/* The third, opened from the second. */}
              <Sheet.Next name="remove">
                {(target: Item) => (
                  <>
                    <Sheet.Header
                      title={`Remove ${target.name.toLowerCase()}?`}
                      description="You can add it again until the order is packed on Friday evening."
                    />
                    <Sheet.Footer>
                      <Sheet.Close
                        render={
                          <Button
                            size="lg"
                            variant="destructive"
                            onClick={() => setItems((all) => all.filter((each) => each.id !== target.id))}
                          />
                        }
                      >
                        Remove
                      </Sheet.Close>
                      <Sheet.Close render={<Button size="lg" variant="ghost" />}>Keep it</Sheet.Close>
                    </Sheet.Footer>
                  </>
                )}
              </Sheet.Next>
            </>
          )}
        </Sheet.Next>
      </Sheet.Content>
    </Sheet>
  );
}

A sheet from a sheet, from any edge

Stacking works from every side. A Sheet.Next rises from the edge of the sheet it is declared in unless it is given a side. The sheet behind is pushed inward from its own edge, so a strip of it still shows.

'use client';

import { UsersRoundIcon } from 'lucide-react';
import { Button } from '@/components/panelui/button';
import { Field } from '@/components/panelui/field';
import { Input } from '@/components/panelui/input';
import { Frame } from '@/components/panelui/frame';
import { Sheet, type SheetSide } from '@/components/panelui/sheet';

const SIDES: SheetSide[] = ['top', 'right', 'bottom', 'left'];

function Workspace({ side }: { side: SheetSide }) {
  return (
    <Sheet side={side}>
      <Sheet.Trigger render={<Button variant="outline" className="capitalize" />}>{side}</Sheet.Trigger>
      <Sheet.Content>
        <Sheet.Header title="Workspace" description="Northwind Studio · 12 members" />
        <Sheet.Body className="flex flex-col gap-6">
          <Field>
            <Field.Label>Workspace name</Field.Label>
            <Input defaultValue="Northwind Studio" />
          </Field>
          <Frame variant="plain">
            <Frame.Panel>
              <Sheet.Trigger to="invite" render={<Frame.Row chevron />}>
                <Frame.Media className="text-muted-foreground">
                  <UsersRoundIcon className="size-4" />
                </Frame.Media>
                <Frame.Content>
                  <Frame.Title as="p">Invite people</Frame.Title>
                  <Frame.Description>They join as members</Frame.Description>
                </Frame.Content>
              </Sheet.Trigger>
            </Frame.Panel>
          </Frame>
        </Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close render={<Button size="lg" />}>Save</Sheet.Close>
        </Sheet.Footer>

        {/* It comes from the same edge, and the first sheet steps back. */}
        <Sheet.Next name="invite">
          <Sheet.Header title="Invite people" description="They join as members and can be promoted later." />
          <Sheet.Body>
            <Field>
              <Field.Label>Email</Field.Label>
              <Input type="email" placeholder="name@northwind.studio" />
            </Field>
          </Sheet.Body>
          <Sheet.Footer>
            <Sheet.Close render={<Button size="lg" />}>Send invite</Sheet.Close>
          </Sheet.Footer>
        </Sheet.Next>
      </Sheet.Content>
    </Sheet>
  );
}

export default function SheetNestedSides() {
  return (
    <div className="grid grid-cols-2 gap-2 sm:grid-cols-4">
      {SIDES.map((side) => (
        <Workspace key={side} side={side} />
      ))}
    </div>
  );
}

The page steps back

Everything inside Sheet.Stage steps back slightly while a sheet is open, so the sheet sits on a layer above the page. Here the stage sits in a frame with 32px corners, so --stage-radius is 26px.

'use client';

import { Button } from '@/components/panelui/button';
import { Table } from '@/components/panelui/table';
import { Card } from '@/components/panelui/card';
import { Sheet } from '@/components/panelui/sheet';

const ACTIVITY = [
  { name: 'Rent', date: '1 Oct', amount: '−£1,240.00' },
  { name: 'Salary', date: '30 Sep', amount: '+£3,180.00' },
  { name: 'Grocer’s', date: '29 Sep', amount: '−£46.20' },
  { name: 'Train pass', date: '28 Sep', amount: '−£128.00' },
];

const DESTINATIONS = ['To savings', 'To a friend', 'Pay a bill', 'Top up card'];

export default function SheetStageDemo() {
  return (
    <div className="w-full max-w-sm overflow-hidden rounded-[2rem] border">
      <Sheet.Stage className="[--stage-radius:26px]">
        <div className="flex flex-col gap-3 p-3">
          <Card size="sm" className="rounded-[20px]">
            <Card.Header>
              <Card.Description>Current account</Card.Description>
              <Card.Title className="text-3xl tracking-tight">£2,914.06</Card.Title>
            </Card.Header>
            <Card.Content>
              <Table>
                <Table.Body>
                  {ACTIVITY.map((row) => (
                    <Table.Row key={row.name}>
                      <Table.Cell>{row.name}</Table.Cell>
                      <Table.Cell className="text-muted-foreground">{row.date}</Table.Cell>
                      <Table.Cell className="text-end tabular-nums">{row.amount}</Table.Cell>
                    </Table.Row>
                  ))}
                </Table.Body>
              </Table>
            </Card.Content>
          </Card>
          <Sheet>
            <Sheet.Trigger render={<Button size="lg" />}>Move money</Sheet.Trigger>
            <Sheet.Content>
              <Sheet.Header title="Move money" description="From your current account" />
              <Sheet.Footer>
                {DESTINATIONS.map((label) => (
                  <Sheet.Close key={label} render={<Button size="lg" variant="outline" />}>
                    {label}
                  </Sheet.Close>
                ))}
              </Sheet.Footer>
            </Sheet.Content>
          </Sheet>
        </div>
      </Sheet.Stage>
    </div>
  );
}

API Reference

Sheet

PropTypeDefaultDescription
openboolean—Whether the sheet is open, when the caller holds that.
onOpenChange(open: boolean) => void—Called when the sheet asks to open or close.
onOpenChangeComplete(open: boolean) => void—Called once it has finished opening or closing, after its transition has ended. false means the exit is over, so a sheet mounted from state can be unmounted.
defaultOpenbooleanfalseWhether it starts open, when the caller does not hold it.
sideSheetSidebottomThe edge it rises from and is swiped back to. Default bottom.
dismissiblebooleantrueWhether a click outside, a swipe or Escape closes it. Turn it off for a sheet that must be answered; Sheet.Close still works.

Sheet.Trigger

PropTypeDefaultDescription
renderReactElement—Your own element to be the trigger, such as a styled button. It is given the click handler and the attributes that tie it to the sheet.
tostring—The name of a Sheet.Next to open instead of the sheet this trigger is in. Any button in a sheet can open the next one this way, wherever it sits.
payloadunknown—Handed to the Sheet.Next that to names, as the argument of its children function. Use it to open one sheet for every row of a list.

Sheet.Next

PropTypeDefaultDescription
namestring—What a Sheet.Trigger passes as to to open this sheet. Unique within one stack of sheets.
sideSheetSidebottomThe edge it rises from. Default: the edge of the sheet it is declared in.
dismissiblebooleantrueWhether a click outside, a swipe or Escape closes it. Default true.
onOpenChange(open: boolean) => void—Called when it opens or closes.
onOpenChangeComplete(open: boolean) => void—Called once it has finished opening or closing, after its transition has ended. false means the exit is over, so a sheet mounted from state can be unmounted.

Sheet.Content

PropTypeDefaultDescription
detachedbooleantrueStand clear of the screen edges with every corner rounded. On by default; off, the sheet meets the edges it rises from.
size'auto' | 'half' | 'full''auto'How tall a top or bottom sheet is. auto fits the content; half and full take that share of the screen, and full meets the edges.
showGrabberboolean—Show the grabber. On by default for a top or bottom sheet that a swipe can close, and off when dismissible is.
showClosebooleantrueShow the round close button in the top trailing corner. Default true. Write a bare <Sheet.Close /> into the sheet to place it somewhere else, or set this to false for a sheet with no close button at all.
blurbooleanfalseFrost the page behind the sheet instead of only dimming it.
inlinebooleanfalseDraw the sheet in the page instead of over it: no backdrop, no trigger, always there. For previews and for a layout that shows the sheet as part of a screen.

Sheet.Header

PropTypeDefaultDescription
titleReactNode—The heading. In an open sheet it is also what the sheet is announced as.
descriptionReactNode—A line under the heading.

Sheet.Close

PropTypeDefaultDescription
renderReactElement—Your own element to close the sheet with, such as a Cancel button. Without it, and without children, this is the round close button, drawn where it is written in place of the one in the corner.
iconboolean—Draw the round close button. A Sheet.Close with nothing inside it already is one.

Sheet.Slides

PropTypeDefaultDescription
snapbooleantruetrue makes it a deck: each slide fills the height, and a scroll glides to the next one. false makes it a numbered column of smaller slides that scrolls freely. Default true.
indexnumber—The current slide, counted from 0, when the caller holds it. Setting it scrolls that slide into view.
defaultIndexnumber0The slide to start on, when the caller does not hold it. Default 0.
onIndexChange(index: number) => void—Called with the new index when the current slide changes: scrolled to in a deck, pressed in a column. In a column, passing it makes each slide a button.
counterboolean—Show "3 / 8" under the current slide. Default: on in a deck.
aspectstring'16 / 9'The shape of a slide in a column, as a CSS aspect ratio. Default 16 / 9.

Sheet.Slide

PropTypeDefaultDescription
labelstring—What a screen reader calls it, after its place: "3 of 8, Harbour at dawn". An image's alt usually says it already.
aspectstring—Its shape in a column, overriding Sheet.Slides' aspect.

Every part also takes the props of the element it renders, and a className.

Notes

Closing a stack

A press outside the sheets closes all of them. Escape, a swipe and Sheet.Close close only the one on top, and the one behind it comes forward again.

Names

A Sheet.Next name is shared by every sheet in one stack, so a trigger finds its sheet however deep either of them is. Use each name once per stack.

A sheet written as a plain <Sheet> inside another sheet's content also stacks. That needs its trigger wrapped in it, so use Sheet.Next when the trigger and the sheet are apart.

Gestures

Swiping follows the pointer, and a quick flick toward the edge closes the sheet even when it has not moved far.

With a mouse, a press on text selects it instead of starting a drag. The grabber and the padding around the header still drag the sheet. Touch swipes from anywhere, except while text in the sheet is selected.

dismissible={false} keeps a click outside, Escape and a swipe from closing it. Only Sheet.Close and your own open state close it then.

size applies to top and bottom sheets. Side sheets always run the full height.

Focus moves into the sheet when it opens and returns to the trigger when it closes. The page behind cannot be scrolled or focused while it is open.

With reduced motion turned on, the sheet appears and disappears without sliding.

Slides need a height

A deck fills the height it is given, so put it in a sheet that has one: a side sheet, or a top or bottom sheet with size="half" or size="full". In a sheet that sizes itself to its content it falls back to 60% of the screen, at most 32rem. A column needs no height of its own; it scrolls once it reaches the edge of the screen.

Server Components

Sheet is a client component. In a file that starts with "use client", write its parts with a dot, as on this page. A Server Component cannot read Sheet.Trigger off the import, so each part is also exported by name: SheetTrigger is Sheet.Trigger, and so on for the others.

import { Sheet, SheetTrigger, SheetNext, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetBody, SheetFooter, SheetClose, SheetStage, SheetSlides, SheetSlide } from "@/components/panelui/sheet"

On this page