Sheet

Extends the Dialog component to display content that complements the main screen. Slides in from the edge of the viewport.

Preview

Installation

Use the CLI to add this component to your project.

npx shadcn@latest add https://ui.nyxhora.com/r/sheet.json

Usage

tsx
41 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
  Sheet,
  SheetContent,
  SheetDescription,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
  SheetFooter,
  SheetClose,
} from "@/components/ui/sheet"

export const metadata = generateComponentMetadata({
    name: "Sheet",
    description: "Extends the Dialog component to display content that complements the main screen. Slides in from the edge of the viewport.",
    category: "Overlay",
});


export default function MyComponent() {
  return (
    <Sheet>
      <SheetTrigger asChild>
        <Button variant="outline">Open</Button>
      </SheetTrigger>
      <SheetContent>
        <SheetHeader>
          <SheetTitle>Sheet Title</SheetTitle>
          <SheetDescription>
            Sheet description goes here.
          </SheetDescription>
        </SheetHeader>
        {/* Content */}
        <SheetFooter>
          <SheetClose asChild>
            <Button>Close</Button>
          </SheetClose>
        </SheetFooter>
      </SheetContent>
    </Sheet>
  )
}

Side Variants

Use the side prop to control which edge of the screen the sheet slides in from.

Right (Default)

Left

Top

Bottom

components/ui/sheet.tsx
2 lines
1
2
Error reading file: /components/ui/sheet.tsx
Error: ENOENT: no such file or directory, open '/vercel/path0/components/ui/sheet.tsx'

Props

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left'rightThe edge of the screen the sheet slides in from
openbooleanundefinedControlled open state of the sheet
onOpenChange(open: boolean) => voidundefinedCallback when the open state changes
modalbooleantrueWhether to render the sheet in a portal with overlay

Sub-components

Sheet

The root component that manages sheet state.

SheetTrigger

The button that opens the sheet. Use asChild to render your own button.

SheetContent

Contains the content that is displayed when the sheet is open. Accepts side prop.

SheetHeader

Contains the title and description of the sheet.

SheetTitle

The title of the sheet.

SheetDescription

The description of the sheet.

SheetFooter

Contains the footer content, typically action buttons.

SheetClose

A button that closes the sheet. Use asChild to render your own button.