shadcn.io is not affiliated with official shadcn/ui
Installation
bunx --bun shadcn@latest add https://kit.dev/r/base/sheet.jsonnpx shadcn@latest add https://kit.dev/r/base/sheet.jsonpnpm dlx shadcn@latest add https://kit.dev/r/base/sheet.jsonyarn shadcn@latest add https://kit.dev/r/base/sheet.jsonThis component depends on Button. Install it first if you haven't already.
Install the following dependencies:
bun add @base-ui/react tailwind-variants lucide-reactnpm install @base-ui/react tailwind-variants lucide-reactpnpm add @base-ui/react tailwind-variants lucide-reactyarn add @base-ui/react tailwind-variants lucide-reactCopy and paste the following code into your project.
"use client";
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
import { XIcon } from "lucide-react";
import type React from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/registry/base/components/button";
export const Sheet = (props: SheetPrimitive.Root.Props) => (
<SheetPrimitive.Root data-slot="sheet" {...props} />
);
export const SheetTrigger = (props: SheetPrimitive.Trigger.Props) => (
<SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
);
export const SheetClose = (props: SheetPrimitive.Close.Props) => (
<SheetPrimitive.Close data-slot="sheet-close" {...props} />Update the import paths to match your project setup.
Anatomy
SheetTrigger
SheetOverlay
SheetPositioner
SheetContent
SheetTitle
SheetDescription
SheetCloseUsage
import { Button } from "@/components/ui/button";
import { Field, 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="outline">Open</Button>
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Edit profile</SheetTitle>
<SheetDescription>
Make changes to your profile here. Click save when you're done.
</SheetDescription>
</SheetHeader>
<div className="grid flex-1 auto-rows-min gap-6 px-4">
<Field className="grid gap-3">
<FieldLabel>Name</FieldLabel>
<Input defaultValue="Pedro Duarte" type="text" />
</Field>
<Field className="grid gap-3">
<FieldLabel>Username</FieldLabel>
<Input defaultValue="@peduarte" type="text" />
</Field>
</div>
<SheetFooter>
<Button type="submit">Save changes</Button>
<SheetClose asChild>
<Button variant="outline">Close</Button>
</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>Accessibility
| Key | Description |
|---|---|
Enter | Activate the focused control. |
Space | Activate the focused control. |
Demos
Side
Use the side prop on SheetContent to set the edge of the screen where the sheet appears.
No Close Button
Use showCloseButton={false} on SheetContent to hide the close button.
Rtl
Right-to-left sheet. See the RTL configuration guide for document direction.
API Reference
Sheet
PropType
AttributeType
SheetTrigger
button
PropType
AttributeType
SheetOverlay
div
PropType
AttributeType
SheetTitle
h2
PropType
AttributeType
SheetDescription
p
PropType
AttributeType
SheetClose
button
PropType
AttributeType
SheetPortal
div
PropType
AttributeType
SheetContent
PropType
AttributeType
SheetHeader
PropType
AttributeType
SheetFooter
PropType
AttributeType