Drawer
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.
When to use
Section titled “When to use”- 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
mdup 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.
Anatomy
Section titled “Anatomy”- 1Handle
- 2Bottom sheet
- 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)).
Variants
Section titled “Variants”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> )}<script setup lang="ts">import { useId } from "vue"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" },]const id = useId()</script>
<template> <Drawer> <DrawerTrigger as-child> <Button variant="outline">Urutkan</Button> </DrawerTrigger> <DrawerContent> <DrawerHeader> <DrawerTitle>Urutkan rilis</DrawerTitle> <DrawerDescription>Pilih urutan daftar rilismu.</DrawerDescription> </DrawerHeader> <RadioGroup default-value="newest" aria-label="Urutan" class="px-4"> <div v-for="o in orders" :key="o.value" class="flex items-center gap-3"> <RadioGroupItem :id="`${id}-${o.value}`" :value="o.value" /> <Label :for="`${id}-${o.value}`">{{ o.label }}</Label> </div> </RadioGroup> <DrawerFooter> <DrawerClose as-child> <Button>Terapkan</Button> </DrawerClose> </DrawerFooter> </DrawerContent> </Drawer></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';
const sortOrders = [('newest', 'Terbaru'), ('oldest', 'Terlama'), ('title', 'Judul A–Z')];
// A bottom sheet: the shadcn_ui sheet from the bottom edge, with a drag handle on top.class DrawerDemo extends StatelessWidget { const DrawerDemo({super.key});
@override Widget build(BuildContext context) { return ShadButton.outline( child: const Text('Urutkan'), onPressed: () => showShadSheet( context: context, side: ShadSheetSide.bottom, builder: (context) { final theme = ShadTheme.of(context); final handle = ExcludeSemantics( child: Center( child: Container( width: 48, height: 6, decoration: BoxDecoration(color: theme.colorScheme.muted, borderRadius: BorderRadius.circular(3)), ), ), ); // draggable lets the handle swipe the sheet closed; the handle sits above the title. return ShadSheet( draggable: true, radius: const BorderRadius.vertical(top: Radius.circular(16)), title: Column(spacing: 12, children: [handle, const Text('Urutkan rilis')]), description: const Text('Pilih urutan daftar rilismu.'), actions: [ShadButton(child: const Text('Terapkan'), onPressed: () => Navigator.of(context).pop())], child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, spacing: 16, children: [ ShadRadioGroup<String>( initialValue: 'newest', items: [for (final (value, label) in sortOrders) ShadRadio(value: value, label: Text(label))], ), ], ), ); }, ), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/drawer.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/drawer.jsonAccessibility
Section titled “Accessibility”- 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.
