React Drawer and Bottom Sheet
A glass React drawer that slides in from any edge, with bottom sheets you can drag, snap and swipe away. Use it as a bottom sheet for filters on a mobile product list, with snap points such as peek, half and full so people can glance at the filters or expand them to full height.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/drawer.jsonHeadphones
148 results
DrawerDrawerBodyDrawerCloseDrawerTitleDrawerFooter- +13 more
- +10 more
Bottom sheet
Swipe the sheet down (or press Escape, or tap outside) to dismiss it. Releasing a quick flick keeps its momentum; a button close is shorter and never overshoots.
import { Button } from "@/components/sheenui/button/button";
import { Drawer, DrawerClose, DrawerTrigger } from "@/components/sheenui/drawer/drawer";
import { DrawerContent } from "@/components/sheenui/drawer/parts/content";
import { DrawerBody, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle } from "@/components/sheenui/drawer/parts/parts";
import { Input } from "@/components/sheenui/input/input";
// Package build (after the first npm release, or a packed tarball): import { Button, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Input } from "@sheenui/theme";
// This example also uses button, input: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/input.json
const targets = [{ label: "Copy link" }, { label: "Email" }, { label: "Chat app" }];
const share = (target: { label: string }) => console.log("share via", target.label);
export function Example() {
return (
<Drawer>
<DrawerTrigger render={<Button />}>Share</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Share “Q3 roadmap”</DrawerTitle>
<DrawerDescription>Anyone in Acme with the link can view and comment.</DrawerDescription>
</DrawerHeader>
<DrawerBody>
{targets.map((t) => (
<DrawerClose key={t.label} onClick={() => share(t)}>{t.label}</DrawerClose>
))}
<Input label="Link" readOnly defaultValue="https://example.com/d/q3-roadmap" />
</DrawerBody>
<DrawerFooter>
<DrawerClose render={<Button variant="glass" />}>Done</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}Files to copy
5 folders · 9 files · 4 packages
- From
theme/src/ components/drawer/drawer.tsxcomponents/drawer/parts/{content.tsx, model.ts, parts.tsx}hooks/{use-direction.ts, use-latest.ts}lib/{cn.ts, form.ts, modal-tab-trap.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/drawer.jsonRegistry item: drawer. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/button/components/input/components/spinner/components/switch/hooks/{use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, tokens.ts}lib/{field-control-shell.tsx, field-size.ts, motion-props.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/input.json https://lokendra-builds.github.io/sheenui/r/switch.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Snap points
Peek, half and full heights. Peek is measured from the content (handle, header and the first row) and half always shows more than peek, even on a landscape phone. Drag between them, flick to skip one, or use the handle: it is a button that reads out the current height (Enter cycles, arrow keys step). Keyboard focus is never hidden: rows scroll into view inside the sheet, and a control that can't (below the screen edge) opens it fully. A click or tap never changes the height.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Drawer, DrawerTrigger } from "@/components/sheenui/drawer/drawer";
import { DrawerContent } from "@/components/sheenui/drawer/parts/content";
import { type DrawerSnapPoint } from "@/components/sheenui/drawer/parts/model";
import { DrawerBody, DrawerDescription, DrawerHeader, DrawerTitle } from "@/components/sheenui/drawer/parts/parts";
// Package build (after the first npm release, or a packed tarball): import { Button, Drawer, DrawerBody, DrawerContent, DrawerDescription, DrawerHeader, type DrawerSnapPoint, DrawerTitle, DrawerTrigger } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
const places = [{ name: "Café Aurora" }, { name: "Riverside Park" }, { name: "Night Market" }];
export function Example() {
// "peek" = handle + header + first row (measured); "half" = 50% of the screen, at least a row above peek.
// Your own heights work too: snapPoints={["148px", 0.6, 1]}
// Translate the handle: labels={{ snapPoints: { half: "Halbe Höhe" } }}
const [snap, setSnap] = useState<DrawerSnapPoint | null>("half");
return (
<Drawer snapPoints={["peek", "half", "full"]} snapPoint={snap} onSnapPointChange={setSnap}>
<DrawerTrigger render={<Button variant="glass" />}>Nearby places</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Nearby</DrawerTitle>
<DrawerDescription>12 places within 2 km.</DrawerDescription>
</DrawerHeader>
<DrawerBody>{places.map((p) => (
<p key={p.name}>{p.name}</p>
))}</DrawerBody>
</DrawerContent>
</Drawer>
);
}Side and top sheets
side picks the edge (and the swipe direction that closes it). inset floats the panel off the edges with rounded corners.
import { Button } from "@/components/sheenui/button/button";
import { Drawer, DrawerClose, DrawerTrigger } from "@/components/sheenui/drawer/drawer";
import { DrawerContent } from "@/components/sheenui/drawer/parts/content";
import { DrawerBody, DrawerFooter, DrawerHeader, DrawerTitle } from "@/components/sheenui/drawer/parts/parts";
import { Input } from "@/components/sheenui/input/input";
import { Switch } from "@/components/sheenui/switch/switch";
// Package build (after the first npm release, or a packed tarball): import { Button, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, Input, Switch } from "@sheenui/theme";
// This example also uses button, input, switch: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/input.json https://lokendra-builds.github.io/sheenui/r/switch.json
export function Example() {
return (
<>
<Drawer side="left">
<DrawerTrigger render={<Button variant="glass" />}>Menu</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Menu</DrawerTitle>
</DrawerHeader>
<DrawerBody>
<DrawerClose render={<Button variant="ghost" fullWidth />}>Home</DrawerClose>
<DrawerClose render={<Button variant="ghost" fullWidth />}>Projects</DrawerClose>
</DrawerBody>
</DrawerContent>
</Drawer>
<Drawer side="right">
<DrawerTrigger render={<Button variant="glass" />}>Settings</DrawerTrigger>
<DrawerContent inset>
<DrawerHeader>
<DrawerTitle>Notification settings</DrawerTitle>
</DrawerHeader>
<DrawerBody>
<Input label="Email" type="email" defaultValue="ada@example.com" />
<Switch label="Mentions" defaultChecked />
</DrawerBody>
<DrawerFooter>
<DrawerClose render={<Button variant="ghost" />}>Cancel</DrawerClose>
<DrawerClose render={<Button />}>Save</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
<Drawer side="top">
<DrawerTrigger render={<Button variant="glass" />}>Announcement</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>What's new</DrawerTitle>
</DrawerHeader>
<DrawerFooter>
<DrawerClose render={<Button />}>Got it</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
</>
);
}Nested sheets
A drawer opened from inside another one stacks on top; the one behind steps back and dims. Swipe or Escape closes only the front one.
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Drawer, DrawerClose, DrawerTrigger } from "@/components/sheenui/drawer/drawer";
import { DrawerContent } from "@/components/sheenui/drawer/parts/content";
import { DrawerBody, DrawerFooter, DrawerHeader, DrawerTitle } from "@/components/sheenui/drawer/parts/parts";
// Package build (after the first npm release, or a packed tarball): import { Button, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
const standard = { id: "standard", label: "Standard · free" };
const options = [standard, { id: "express", label: "Express · $5" }];
export function Example() {
const [delivery, setDelivery] = useState("standard");
const chosen = options.find((o) => o.id === delivery) ?? standard;
return (
<Drawer>
<DrawerTrigger render={<Button />}>Cart (3)</DrawerTrigger>
<DrawerContent>
<DrawerHeader><DrawerTitle>Your cart</DrawerTitle></DrawerHeader>
<DrawerBody>
<p>3 items · $126.00</p>
<Drawer>
<DrawerTrigger>Delivery: {chosen.label}</DrawerTrigger>
<DrawerContent>
<DrawerHeader><DrawerTitle>Delivery</DrawerTitle></DrawerHeader>
<DrawerBody>{options.map((o) => <DrawerClose key={o.id} onClick={() => setDelivery(o.id)}>{o.label}</DrawerClose>)}</DrawerBody>
</DrawerContent>
</Drawer>
</DrawerBody>
<DrawerFooter>
<DrawerClose render={<Button fullWidth />}>Pay $131</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}Drawer
DrawerLabelsInput keys and English defaults (6)
DrawerContent
Parts
Keyboard
Accessibility
- A modal dialog (Base UI): named by DrawerTitle, described by DrawerDescription; the page behind is inert.
- The handle is a real button with snap points and tells screen readers the current height. A swipe is a shortcut: a button always closes it.
- Under reduced motion the sheet fades instead of sliding.
All exports on this page
Drawer— Drawer / sheet: a strong-glass panel that slides in from an edge of the screen.DrawerBody— The scrolling part of the sheet.DrawerClose— A button inside the drawer that closes it (a "Done" or "Cancel" action in DrawerFooter).DrawerContent— The glass panel of a Drawer, portalled to the end of the body with a dimmed scrim (for a modal drawer).DrawerDescription— Muted helper text under the title.DrawerFooter— Bottom row of actions, separated by a hairline: a column on phones (primary action first on screen) and a right-aligned row from sm up.DrawerHandle— The grab bar.DrawerHeader— Top section of the sheet: stacks the title and description, with room on the right for the × button.DrawerSwipeArea— An invisible strip along a screen edge that opens the drawer with a swipe (touch screens).DrawerTitle— The drawer's heading.DrawerTrigger— The element that opens a Drawer (a <button> by default; use render={<Button />} for a SheenUI button).createDrawerHandle— Connects a Drawer to triggers rendered elsewhere: <Drawer handle={h}> + <DrawerTrigger handle={h}>.createSideDrawerHandle— Connects a SideDrawer to triggers rendered elsewhere: <SideDrawer handle={h}> + <SideDrawerTrigger handle={h}>.defaultDrawerLabels— Default English strings of DrawerLabels; spread it and override single keys to reword.drawerSnapPresets— Starting values of the presets.
When to use the Drawer / Sheet
- Use it for a mobile bottom sheet that people drag between a peek, half and full height, such as filters on a product list or a place card on a map, or as a side panel on desktop.
- Use it for a navigation menu or cart panel sliding in from the left or right with side="left" or "right", or floating off the edge with the inset prop on DrawerContent.
- Use it for a quick form on a phone, where keyboardAware (on by default) keeps focused fields above the on-screen keyboard while the sheet remains swipeable.
- Skip it when you need a centered modal, which Dialog handles, or a record detail and edit panel with close guards and resizing, where SideDrawer is built for that.
- Pair it with Button through the render prop on DrawerTrigger, Tabs or RadioGroup inside DrawerBody for filter controls, and Toast to report that the applied choices were saved.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .