Skip to content

Drawer

A temporary side surface for focused work.

OverlaySurface
npx shadcn@latest add @silicon-ui/drawer

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/drawer

Manually

  1. Install the dependencies

    npm install @radix-ui/react-dialog lucide-react motion
  2. Copy these files into your project

    • components/silicon-ui/drawer/drawer.tsx
    • components/silicon-ui/drawer/drawer.module.css

    Shared with other components. Skip any you already have.

    • components/silicon-ui/lib/escape.ts
    • components/silicon-ui/lib/return-focus.ts
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { Drawer } from "@/components/silicon-ui/drawer/drawer";

API reference

Drawer

Accepts the props of DialogProps.

DrawerContent

PropTypeDefault
title*string—
children*ReactNode—
descriptionstring—
side"left" | "right" | "top" | "bottom""right"
container

Renders the drawer inside this element instead of the page body, anchored to its edges. The element needs position: relative and overflow: hidden.

HTMLElement | null—

Also accepts the props of ComponentPropsWithoutRef<typeof DialogPrimitive.Content>.

DrawerTrigger

Accepts the props of ButtonHTMLAttributes.

DrawerClose

Accepts the props of ButtonHTMLAttributes.

Dependencies

npm
@radix-ui/react-dialoglucide-reactmotion
Registry
silicon-motion-tokens