Install
Pull Drawer from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Drawer } from "@brika/clay";import { Drawer } from "@brika/clay/components/drawer";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import { Button } from '@brika/clay/components/button';
import {
Drawer,
DrawerClose,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from '@brika/clay/components/drawer';
/** Bottom-sheet overlay, drag the handle or tap outside to close. */
export default function DrawerDefaultDemo() {
return (
<Drawer>
<DrawerTrigger asChild>
<Button variant="outline">Open drawer</Button>
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
<DrawerTitle>Publish changes</DrawerTitle>
<DrawerDescription>
Review and confirm before pushing to production.
</DrawerDescription>
</DrawerHeader>
<DrawerFooter>
<Button>Publish</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
);
}Drawer, every way
Accessibility
- Focus is trapped inside the drawer while open.
- Escape dismisses the drawer; the drag handle is decorative and keyboard users dismiss with Escape.
-
DrawerTitleis required for an accessible name. - Ensure scrollable content inside the drawer is reachable by keyboard, not only by touch-drag.
Theme tokens
Every CSS variable Drawer reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Drawer
without touching component code.
Drawer tokens
14 tokens--drawer-surface-containercolorvar(--popover)components.drawer.surfaceContainerBackground of the drawer panel.
--drawer-overlay-colorcoloroklch(0 0 0 / 0.5)components.drawer.overlayColorColor of the modal scrim shown behind an open drawer. Defaults to black at 50% opacity.
--drawer-handle-colorcolorvar(--muted)components.drawer.handleColorFill of the small horizontal handle pill drawn at the top of the drawer panel.
--drawer-description-colorcolorvar(--muted-foreground)components.drawer.descriptionColorForeground color of the drawer description text.
--drawer-radiusradiusvar(--radius-container)components.drawer.radiusDrawer sheet top-corner radius.
--drawer-padding-xsizecalc(var(--spacing) * 6)components.drawer.paddingXInline padding inside the drawer.
--drawer-padding-ysizecalc(var(--spacing) * 4)components.drawer.paddingYBlock padding inside the drawer.
--drawer-gapsizecalc(var(--spacing) * 2)components.drawer.gapGap between adjacent children inside the drawer.
--drawer-border-widthborder-width1pxcomponents.drawer.borderWidthBorder width on the drawer. Set non-zero for outline-style variants.
--drawer-border-styleborder-stylesolidcomponents.drawer.borderStyleBorder style on the drawer (`solid`, `dashed`, `double`, `none`).
--drawer-shadowshadowvar(--shadow-overlay)components.drawer.shadowDrawer elevation.
--drawer-backdrop-blurblur0pxcomponents.drawer.backdropBlurBackdrop blur behind translucent drawer.
--drawer-durationdurationvar(--motion-standard-duration)components.drawer.durationTransition duration for drawer state changes.
--drawer-easingeasingvar(--motion-standard-easing)components.drawer.easingTransition easing for drawer state changes.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.drawer, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"drawer": {
"paddingX": "calc(var(--spacing) * 6)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-drawer-…) — see the
chips on each token row.
API reference
Props specific to Drawer. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<DrawerContent />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DrawerDescription />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DrawerFooter />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DrawerHeader />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DrawerOverlay />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<DrawerTitle />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.