Containment · Material 3: Bottom sheets, Side sheets
Sheet
A panel that slides in from an edge. variant="draggable" makes a bottom sheet you can drag, flick and snap.
Examples and variants
Modal, any side
side="end | start | top | bottom".
function SheetSide() {
return (
<div className="flex flex-wrap justify-center gap-3">
{(["end", "start", "bottom"] as const).map((side) => (
<Sheet key={side}>
<SheetTrigger render={<Button variant="secondary" />}>Side {side}</SheetTrigger>
<SheetContent side={side}>
<SheetHeader>
<SheetTitle>Filters</SheetTitle>
<SheetDescription>Slides in from the {side} edge.</SheetDescription>
</SheetHeader>
<Filters />
<SheetFooter>
<SheetClose render={<Button />}>Show results</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>
))}
</div>
)
}Draggable variant
For phones. The handle stretches while you drag.
function SheetDraggable() {
return (
<Sheet variant="draggable">
<SheetTrigger render={<Button variant="secondary" />}>Open draggable sheet</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Filters</SheetTitle>
<SheetDescription>Drag the handle. A flick down closes it.</SheetDescription>
</SheetHeader>
<Filters />
<SheetFooter>
<SheetClose render={<Button />}>Show results</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>
)
}Spec drawing
Measured from the live component at default density. Each code maps to the token that sets it; change the token and the drawing follows.
Install
With the CLI
The shadcn CLI only delivers files: it copies our code from the Isotopi registry into your project and installs the packages it uses. Add the foundation once, then the component.
npx shadcn@latest add https://isotopi.com/r/minimal.json
npx shadcn@latest add https://isotopi.com/r/sheet.jsonBy hand
No CLI needed. Add the foundation once (see Getting started), then follow these steps. They include every component this one builds on.
Install the packages it uses.
Terminalnpm install @base-ui/react cnCopy this file to the same paths in your project. Imports use the
@/alias for your project root.components/ui/sheet.tsxsheet
components/ui/sheet.tsx"use client" import * as React from "react" import { Dialog as DialogPrimitive } from "@base-ui/react/dialog" import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer" import { cn } from "cn" import { usePortalMotion } from "@/lib/overlay" /* One Sheet for every panel that slides in from an edge (component-model.md §3). - side: start | end | top | bottom (logical, mirrors in RTL) - draggable: bottom sheets you can drag, flick and snap (phones). Uses Base UI Drawer. - modal={false}: no scrim, the page stays usable (a side panel next to content). Not for a short list of actions: use a Menu from the button. Drawer* exports are presets of this component for shadcn compatibility. */ type Side = "start" | "end" | "top" | "bottom" | "left" | "right" const SheetContext = React.createContext<{ draggable: boolean }>({ draggable: false }) type SheetProps = DialogPrimitive.Root.Props & { /** * modal (default): slides in from `side` with a scrim. * draggable: a bottom sheet that follows the finger, flicks closed and snaps. */ variant?: "modal" | "draggable" /** @deprecated use variant="draggable" */ draggable?: boolean /** Snap points for draggable sheets, as fractions of the sheet height. */ snapPoints?: DrawerPrimitive.Root.Props["snapPoints"] } function Sheet({ variant = "modal", draggable: legacyDraggable, snapPoints, ...props }: SheetProps) { const draggable = variant === "draggable" || legacyDraggable === true return ( <SheetContext.Provider value={{ draggable }}> {draggable ? ( <DrawerPrimitive.Root snapPoints={snapPoints} {...(props as DrawerPrimitive.Root.Props)} /> ) : ( <DialogPrimitive.Root {...props} /> )} </SheetContext.Provider> ) } function SheetTrigger(props: DialogPrimitive.Trigger.Props) { const { draggable } = React.useContext(SheetContext) return draggable ? ( <DrawerPrimitive.Trigger data-slot="sheet-trigger" {...(props as DrawerPrimitive.Trigger.Props)} /> ) : ( <DialogPrimitive.Trigger data-slot="sheet-trigger" {...props} /> ) } function SheetClose(props: DialogPrimitive.Close.Props) { const { draggable } = React.useContext(SheetContext) return draggable ? ( <DrawerPrimitive.Close data-slot="sheet-close" {...(props as DrawerPrimitive.Close.Props)} /> ) : ( <DialogPrimitive.Close data-slot="sheet-close" {...props} /> ) } function SheetTitle({ className, ...props }: DialogPrimitive.Title.Props) { const { draggable } = React.useContext(SheetContext) const Title = draggable ? DrawerPrimitive.Title : DialogPrimitive.Title return <Title className={cn("text-title", className)} {...props} /> } function SheetDescription({ className, ...props }: DialogPrimitive.Description.Props) { const { draggable } = React.useContext(SheetContext) const Description = draggable ? DrawerPrimitive.Description : DialogPrimitive.Description return <Description className={cn("text-sm text-muted-foreground", className)} {...props} /> } function SheetHeader({ className, ...props }: React.ComponentProps<"div">) { return <div data-slot="sheet-header" className={cn("flex flex-col gap-1", className)} {...props} /> } function SheetBody({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="sheet-body" className={cn("flex min-h-0 flex-1 flex-col gap-stack-md overflow-y-auto", className)} {...props} /> ) } function SheetFooter({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="sheet-footer" className={cn("mt-auto flex flex-wrap justify-end gap-inline-sm pt-2", className)} {...props} /> ) } function logical(side: Side): "start" | "end" | "top" | "bottom" { if (side === "left") return "start" if (side === "right") return "end" return side } const edges = { start: "inset-y-0 start-0 w-(--sheet-width) max-w-[calc(100vw-var(--space-6))]", end: "inset-y-0 end-0 w-(--sheet-width) max-w-[calc(100vw-var(--space-6))]", top: "inset-x-0 top-0 max-h-[80vh]", bottom: "inset-x-0 bottom-0 max-h-[80vh]", } as const function SheetContent({ className, children, side = "end", modal = true, ...props }: DialogPrimitive.Popup.Props & { side?: Side /** false: no scrim and the page stays usable. */ modal?: boolean }) { const ref = React.useRef<HTMLDivElement>(null) const { draggable } = React.useContext(SheetContext) usePortalMotion(ref) if (draggable) { return ( <DrawerPrimitive.Portal> <DrawerPrimitive.Backdrop className="overlay-scrim fixed inset-0 z-modal" /> <DrawerPrimitive.Viewport className="fixed inset-0 z-modal flex items-end justify-center"> <DrawerPrimitive.Popup ref={ref} data-slot="sheet-content" data-side="bottom" className={cn( "overlay-surface drawer-panel relative flex max-h-[80vh] w-full flex-col gap-stack-md rounded-t-(--sheet-corner) p-(--sheet-padding) pt-3 text-foreground outline-none sm:max-w-(--layout-dialog-md)", className )} {...(props as DrawerPrimitive.Popup.Props)} > <div aria-hidden className="drawer-handle mx-auto h-(--sheet-handle-height) w-(--sheet-handle-width) shrink-0 rounded-(--radius-pill) bg-(--sheet-handle)" /> {children} </DrawerPrimitive.Popup> </DrawerPrimitive.Viewport> </DrawerPrimitive.Portal> ) } const edge = logical(side) return ( <DialogPrimitive.Portal> {modal ? <DialogPrimitive.Backdrop className="overlay-scrim fixed inset-0 z-modal" /> : null} <DialogPrimitive.Popup ref={ref} data-slot="sheet-content" data-side={edge === "start" ? "left" : edge === "end" ? "right" : edge} className={cn( "overlay-surface sheet-panel fixed z-modal flex flex-col gap-stack-md p-(--sheet-padding) text-foreground outline-none", edges[edge], className )} {...props} > {children} </DialogPrimitive.Popup> </DialogPrimitive.Portal> ) } /* shadcn-compatible presets: a Drawer is a draggable bottom Sheet. */ function Drawer(props: Omit<SheetProps, "variant" | "draggable">) { return <Sheet variant="draggable" snapPoints={[1]} {...props} /> } const DrawerTrigger = SheetTrigger const DrawerClose = SheetClose const DrawerTitle = SheetTitle const DrawerDescription = SheetDescription const DrawerHeader = SheetHeader const DrawerFooter = SheetFooter function DrawerContent(props: React.ComponentProps<typeof SheetContent>) { return <SheetContent side="bottom" {...props} /> } export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetBody, SheetFooter, SheetTitle, SheetDescription, Drawer, DrawerTrigger, DrawerClose, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, }
Imports
What the examples on this page import:
import { Button } from "@/components/ui/button"
import { Label } from "@/components/ui/label"
import {
import { Switch } from "@/components/ui/switch"Anatomy
- 1Scrim · --dialog-scrim (modal only).
- 2Container · --sheet-container, --sheet-padding, --sheet-width; bottom sheets use --sheet-corner.
- 3Handle · Draggable only: --sheet-handle-width x --sheet-handle-height.
- 4Header, Body, Footer · Body scrolls; footer stays at the bottom.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "modal" | "draggable" | "modal" | Draggable is a bottom sheet with drag, flick and snap. |
SheetContent side | "start" | "end" | "top" | "bottom" | "end" | Edge (logical: mirrors in RTL). |
SheetContent modal | boolean | true | false: no scrim, the page stays usable. |
snapPoints | number[] | — | Draggable only. |
Tokens
Every visual spec is a component token in styles/tokens/components.css, pointing at a semantic token. Change a token to restyle the component; themes change the semantic layer.
| Token | Points to | Light | Dark |
|---|---|---|---|
--sheet-container | var(--surface-container-raised) | oklch(1 0 0) | oklch(0.22 0 0) |
--sheet-corner | var(--shape-lg) | 22px | same |
--sheet-padding | var(--space-inset-dialog) | 24px | same |
--sheet-width | var(--layout-sheet) | 400px | same |
--sheet-elevation | var(--elevation-overlay) | 0 1px 2px oklch(0.22 0.01 260 / 6%), 0 2.8px 2.2px oklch(0.22 0.01 260 / 3.4%), 0 6.7px 5.3px oklch(0.22 0.01 260 / 4.8%), 0 12.5px 10px oklch(0.22 0.01 260 / 6%), 0 22.3px 17.9px oklch(0.22 0.01 260 / 7.2%), 0 41.8px 33.4px oklch(0.22 0.01 260 / 8.6%), 0 100px 80px oklch(0.22 0.01 260 / 12%) | 0 16px 36px oklch(0 0 0 / 55%), 0 32px 72px oklch(0 0 0 / 50%) |
--sheet-handle-width | var(--space-10) | 40px | same |
--sheet-handle-height | var(--space-1) | 4px | same |
--sheet-handle | var(--surface-container-high) | oklch(0.94 0.007 95) | oklch(0.27 0 0) |
Motion
| Trigger | What happens | Tokens |
|---|---|---|
| Open | Slides in on the sheet curve; the leading edge settles with a tiny wobble. | --duration-medium, --ease-sheet |
| Drag (draggable) | Follows the finger 1:1; a flick closes; otherwise springs to the nearest snap point. | --spring-snappy |
Calm keeps the motion without overshoot. Still (and reduced motion) keeps a designed frame with no movement.
Accessibility
- Escape closes and focus returns to the trigger.
- The trigger is always a Button (render={<Button />}).
- Always include a visible close action.
Usage
Do
- Use for big panels: filters, details, settings, phone navigation.
Don’t
- Don't use for a short list of actions (use Menu).
Code
"use client"
import * as React from "react"
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer"
import { cn } from "cn"
import { usePortalMotion } from "@/lib/overlay"
/*
One Sheet for every panel that slides in from an edge (component-model.md §3).
- side: start | end | top | bottom (logical, mirrors in RTL)
- draggable: bottom sheets you can drag, flick and snap (phones). Uses Base UI Drawer.
- modal={false}: no scrim, the page stays usable (a side panel next to content).
Not for a short list of actions: use a Menu from the button.
Drawer* exports are presets of this component for shadcn compatibility.
*/
type Side = "start" | "end" | "top" | "bottom" | "left" | "right"
const SheetContext = React.createContext<{ draggable: boolean }>({ draggable: false })
type SheetProps = DialogPrimitive.Root.Props & {
/**
* modal (default): slides in from `side` with a scrim.
* draggable: a bottom sheet that follows the finger, flicks closed and snaps.
*/
variant?: "modal" | "draggable"
/** @deprecated use variant="draggable" */
draggable?: boolean
/** Snap points for draggable sheets, as fractions of the sheet height. */
snapPoints?: DrawerPrimitive.Root.Props["snapPoints"]
}
function Sheet({ variant = "modal", draggable: legacyDraggable, snapPoints, ...props }: SheetProps) {
const draggable = variant === "draggable" || legacyDraggable === true
return (
<SheetContext.Provider value={{ draggable }}>
{draggable ? (
<DrawerPrimitive.Root
snapPoints={snapPoints}
{...(props as DrawerPrimitive.Root.Props)}
/>
) : (
<DialogPrimitive.Root {...props} />
)}
</SheetContext.Provider>
)
}
function SheetTrigger(props: DialogPrimitive.Trigger.Props) {
const { draggable } = React.useContext(SheetContext)
return draggable ? (
<DrawerPrimitive.Trigger data-slot="sheet-trigger" {...(props as DrawerPrimitive.Trigger.Props)} />
) : (
<DialogPrimitive.Trigger data-slot="sheet-trigger" {...props} />
)
}
function SheetClose(props: DialogPrimitive.Close.Props) {
const { draggable } = React.useContext(SheetContext)
return draggable ? (
<DrawerPrimitive.Close data-slot="sheet-close" {...(props as DrawerPrimitive.Close.Props)} />
) : (
<DialogPrimitive.Close data-slot="sheet-close" {...props} />
)
}
function SheetTitle({ className, ...props }: DialogPrimitive.Title.Props) {
const { draggable } = React.useContext(SheetContext)
const Title = draggable ? DrawerPrimitive.Title : DialogPrimitive.Title
return <Title className={cn("text-title", className)} {...props} />
}
function SheetDescription({ className, ...props }: DialogPrimitive.Description.Props) {
const { draggable } = React.useContext(SheetContext)
const Description = draggable ? DrawerPrimitive.Description : DialogPrimitive.Description
return <Description className={cn("text-sm text-muted-foreground", className)} {...props} />
}
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
return <div data-slot="sheet-header" className={cn("flex flex-col gap-1", className)} {...props} />
}
function SheetBody({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-body"
className={cn("flex min-h-0 flex-1 flex-col gap-stack-md overflow-y-auto", className)}
{...props}
/>
)
}
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-footer"
className={cn("mt-auto flex flex-wrap justify-end gap-inline-sm pt-2", className)}
{...props}
/>
)
}
function logical(side: Side): "start" | "end" | "top" | "bottom" {
if (side === "left") return "start"
if (side === "right") return "end"
return side
}
const edges = {
start: "inset-y-0 start-0 w-(--sheet-width) max-w-[calc(100vw-var(--space-6))]",
end: "inset-y-0 end-0 w-(--sheet-width) max-w-[calc(100vw-var(--space-6))]",
top: "inset-x-0 top-0 max-h-[80vh]",
bottom: "inset-x-0 bottom-0 max-h-[80vh]",
} as const
function SheetContent({
className,
children,
side = "end",
modal = true,
...props
}: DialogPrimitive.Popup.Props & {
side?: Side
/** false: no scrim and the page stays usable. */
modal?: boolean
}) {
const ref = React.useRef<HTMLDivElement>(null)
const { draggable } = React.useContext(SheetContext)
usePortalMotion(ref)
if (draggable) {
return (
<DrawerPrimitive.Portal>
<DrawerPrimitive.Backdrop className="overlay-scrim fixed inset-0 z-modal" />
<DrawerPrimitive.Viewport className="fixed inset-0 z-modal flex items-end justify-center">
<DrawerPrimitive.Popup
ref={ref}
data-slot="sheet-content"
data-side="bottom"
className={cn(
"overlay-surface drawer-panel relative flex max-h-[80vh] w-full flex-col gap-stack-md rounded-t-(--sheet-corner) p-(--sheet-padding) pt-3 text-foreground outline-none sm:max-w-(--layout-dialog-md)",
className
)}
{...(props as DrawerPrimitive.Popup.Props)}
>
<div aria-hidden className="drawer-handle mx-auto h-(--sheet-handle-height) w-(--sheet-handle-width) shrink-0 rounded-(--radius-pill) bg-(--sheet-handle)" />
{children}
</DrawerPrimitive.Popup>
</DrawerPrimitive.Viewport>
</DrawerPrimitive.Portal>
)
}
const edge = logical(side)
return (
<DialogPrimitive.Portal>
{modal ? <DialogPrimitive.Backdrop className="overlay-scrim fixed inset-0 z-modal" /> : null}
<DialogPrimitive.Popup
ref={ref}
data-slot="sheet-content"
data-side={edge === "start" ? "left" : edge === "end" ? "right" : edge}
className={cn(
"overlay-surface sheet-panel fixed z-modal flex flex-col gap-stack-md p-(--sheet-padding) text-foreground outline-none",
edges[edge],
className
)}
{...props}
>
{children}
</DialogPrimitive.Popup>
</DialogPrimitive.Portal>
)
}
/* shadcn-compatible presets: a Drawer is a draggable bottom Sheet. */
function Drawer(props: Omit<SheetProps, "variant" | "draggable">) {
return <Sheet variant="draggable" snapPoints={[1]} {...props} />
}
const DrawerTrigger = SheetTrigger
const DrawerClose = SheetClose
const DrawerTitle = SheetTitle
const DrawerDescription = SheetDescription
const DrawerHeader = SheetHeader
const DrawerFooter = SheetFooter
function DrawerContent(props: React.ComponentProps<typeof SheetContent>) {
return <SheetContent side="bottom" {...props} />
}
export {
Sheet,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetBody,
SheetFooter,
SheetTitle,
SheetDescription,
Drawer,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
}