chrome
<tc-drawer>
Side sheet that slides in from any edge, backed by `<dialog>`. Backdrop, Esc, focus management — same primitives as the modal.
import
"@ra9/tan-compose-kit/drawer"
Props
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Whether the drawer is showing. Reflects to the `open` attribute. |
side | "left" | "right" | "top" | "bottom" | "right" | Which edge the drawer slides in from. |
size | string | "min(420px, 92vw)" | Drawer width for left / right; height for top / bottom. Any CSS length. |
dismissible | boolean | true | Backdrop click and Esc dismiss. |
title | string | "" | Optional header title. |
Events
| Event | Detail | When |
|---|---|---|
tc-close | { reason: "backdrop" | "escape" | "button" | "api" } | Fires when the drawer closes. `reason` reports what dismissed it. |
Slots
| Slot | Description |
|---|---|
(default) | Drawer body content. |
footer | Optional action footer (buttons, etc.). |
CSS variables
| Variable | Default | Description |
|---|---|---|
--tc-drawer-bg | var(--tc-color-surface, #ffffff) | Drawer background. |
--tc-drawer-ink | var(--tc-color-ink, #14171f) | Body text color. |
--tc-drawer-rule | var(--tc-color-rule, #ece5d3) | Divider color. |
--tc-drawer-shadow | var(--tc-shadow-lg, …) | Outer shadow. |
--tc-drawer-backdrop | rgba(20, 23, 31, 0.5) | Backdrop dim color. |
--tc-drawer-duration | 260ms | Slide-in / out duration. |
Examples
Right (default)
Left
Bottom
This pattern works well on mobile for action sheets and quick forms.
Programmatic
Accessibility
- Built on the native
<dialog>element withshowModal()— focus is trapped and Esc dismisses for free. - Backdrop click closes when
dismissibleis true. Disable for confirmation flows. - The body region scrolls independently; the header and footer stay pinned.
- Drawers respect
prefers-reduced-motion: reduceand skip the slide transition.