Skip to content

Drawer

Download .md

A drawer is a bottom sheet: a panel that slides up from the bottom of a phone screen, for sorting, filters or a short choice.

  • Use it on phones for sorting, filters and short choices, close to the thumb.
  • Use a Sheet from the side on the web. A web app that must also work on phones opens the Sheet from md up and the Drawer below it.
  • Use a Dialog for a decision that needs the whole attention.
  • Long content scrolls inside the drawer; it never covers more than 85% of the screen.
React
Vue
123
  1. 1Handle
  2. 2Bottom sheet
  3. 3Page behind, dimmed

A 48×6px handle on top, a header with a title and one sentence of description, the content, and a footer with the main action. The panel sits on popover with radius-xl on the top corners only, a border on top and the overlay token behind it. Its bottom padding keeps clear of the phone’s home indicator (env(safe-area-inset-bottom)).

There is one style, from the bottom. Other edges are possible, but use a Sheet for side panels.

React Vue Flutter Type Default Use
open / onOpenChange v-model:open showShadSheet(side: ShadSheetSide.bottom) boolean false Opens it from code.
showSwipeHandle always shown from the bottom a 48×6 muted box boolean true The drag handle.
DrawerTitle, DrawerDescription same title, description text none Names the panel.
DrawerFooter DrawerFooter actions element none The main action.
import { useId } from "react"
import { Button } from "@/components/ui/button"
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from "@/components/ui/drawer"
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
const orders = [
{ value: "newest", label: "Terbaru" },
{ value: "oldest", label: "Terlama" },
{ value: "title", label: "Judul A–Z" },
]
export default function DrawerDemo() {
const id = useId()
return (
<Drawer>
<DrawerTrigger render={<Button variant="outline" />}>Urutkan</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Urutkan rilis</DrawerTitle>
<DrawerDescription>Pilih urutan daftar rilismu.</DrawerDescription>
</DrawerHeader>
<RadioGroup defaultValue="newest" aria-label="Urutan" className="px-4">
{orders.map((o) => (
<div key={o.value} className="flex items-center gap-3">
<RadioGroupItem value={o.value} id={`${id}-${o.value}`} />
<Label htmlFor={`${id}-${o.value}`}>{o.label}</Label>
</div>
))}
</RadioGroup>
<DrawerFooter>
<DrawerClose render={<Button />}>Terapkan</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/drawer.json
  • It is a dialog named by its title; the focus moves into it and back to the trigger when it closes.
  • Dragging the handle down, Escape and a tap on the overlay close it. The handle is decoration and never takes the focus, so keep a button that closes or applies.
  • The page behind it can’t be reached until it closes.