Overlays & Actions
Drawer
Mobile-first panel built on Sheet/Dialog — default bottom `direction`, drag handle, `data-vaul-drawer-direction` for shadcn-style utilities, optional `open`/`onOpenChange`, `DrawerTrigger`/`DrawerClose` with `asChild`. Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/drawer.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Drawer primitives from @/components/kamod-ui/drawer (same surface as shadcn drawer; no Vaul runtime).
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Set direction on Drawer (top | right | bottom | left). DrawerContent defaults showCloseButton to false (use footer actions). Use showHandle={false} to hide the top/bottom affordance bar.
import { Drawer } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Drawer in Different Contexts, from the starting pattern to the compositions below. Begin with Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Demo
Keep the Bottom Panel Focused on One Adjustment. The drawer example combines a goal stepper, a simple bar display and footer actions in one temporary surface. Adjusting the goal changes local demonstration state, letting you inspect the composition before connecting a real save operation.
Connect the displayed value to real application state, define confirmation versus cancellation, and keep the controls usable when the available height is small.
// See repo drawer-doc.tsx — Drawer + DrawerTrigger asChild + DrawerContent + header/footerBasic
Introduce the Task before Adding Controls. Start with a trigger and bottom drawer containing a title and description. This establishes the temporary panel's purpose before adding fields or actions, while leaving the main page recognizable behind it.
Preserve a visible dismissal path and keyboard focus handling, and avoid treating the slide-in presentation as a reason to omit labels or task context.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthScrollable Content
Keep Actions Reachable While the Body Grows. Place long content in a scroll region inside a right-side drawer and keep the footer in the surrounding layout. This allows readers to browse the details while retaining access to the next action.
Check that focused controls remain visible above the footer and test short screens; avoid nesting several competing vertical scroll areas in the same drawer.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthSides
Choose the Edge According to the Surrounding Layout. Choose the drawer's direction according to the edge it should emerge from. Compare all sides with the same content to understand how panel dimensions and available reading space change with that placement.
Keep the content and dismissal behavior consistent across directions, and verify that panel dimensions leave enough space for real labels and actions.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthResponsive Dialog
Preserve the Task Across Breakpoints. Use a Dialog at wider sizes and a Drawer below the md breakpoint while sharing open and onOpenChange. The presentation adapts to the viewport, but the task and its state remain one interaction.
Keep form values outside presentation-specific branches when they must survive a switch, and test resizing while the panel is open rather than only its initial layout.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Drawer using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Drawer
DrawerProps
| Prop / type | Description |
|---|---|
children | Configure
|
defaultOpen | Configure
|
direction | Edge the drawer opens from (shadcn/Vaul `direction`). Default `bottom`.
|
dismissible | When false, Escape and an overlay click leave the dialog open. An explicit close control still closes it. Default true.
|
lockBodyScroll | When true, locks document scroll while open (shadcn default).
|
onOpenChange | Configure
|
open | Configure
|
DrawerClose
DrawerCloseProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
data-slot | Configure
|
DrawerContent
DrawerContentProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
data-slot | Configure
|
forceMount | Configure
|
showCloseButton | Configure
|
showHandle | Drag affordance for top/bottom drawers. Default: `true` when `direction` is top or bottom.
|
DrawerDescription
DrawerDescriptionProps
| Prop / type | Description |
|---|---|
children | Configure
|
DrawerHeader
DrawerHeaderProps
| Prop / type | Description |
|---|---|
children | Configure
|
DrawerTitle
DrawerTitleProps
| Prop / type | Description |
|---|---|
children | Configure
|
DrawerTrigger
DrawerTriggerProps
| Prop / type | Description |
|---|---|
asChild | Configure
|
children | Configure
|
data-slot | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
Drawer Props
2 declared fieldsDrawerPropsDrawer.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerProps before adapting it.DrawerClose Props
DeclarationDrawerClosePropsDrawerClose.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerCloseProps before adapting it.DrawerContent Props
2 declared fieldsDrawerContentPropsDrawerContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerContentProps before adapting it.DrawerDescription Props
DeclarationDrawerDescriptionPropsDrawerDescription.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerDescriptionProps before adapting it.DrawerFooter Props
DeclarationDrawerFooterPropsDrawerFooter.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerFooterProps before adapting it.DrawerHeader Props
DeclarationDrawerHeaderPropsDrawerHeader.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerHeaderProps before adapting it.DrawerTitle Props
DeclarationDrawerTitlePropsDrawerTitle.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerTitleProps before adapting it.DrawerTrigger Props
DeclarationDrawerTriggerPropsDrawerTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerTriggerProps before adapting it.DrawerDirection
DeclarationDrawerDirectiondrawer-context.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerDirection before adapting it.DrawerContextValue
1 declared fieldDrawerContextValuedrawer-context.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerContextValue before adapting it.directionAccessibility
Build the Complete Interaction, Including the Parts Outside Drawer. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
Drawer builds on dialog behavior and adds drawer presentation. The drag handle is decorative and hidden from assistive technology. Dragging is not a substitute for a real close or cancel control.
Labels and Relationships
Provide DrawerTitle and DrawerDescription for context. Label every field and action inside the panel. If using a responsive Dialog/Drawer composition, keep the task wording and logical order consistent across both versions.
Keyboard and Focus
Test keyboard opening, Tab navigation, Escape and explicit dismissal independently of dragging. Keep primary and cancel actions accessible when the onscreen keyboard reduces the available height. A visible handle must not be the only way to close.
States and Integration Details
A drawer's visual motion does not explain its state to a screen reader. Avoid unmounting the focused field during a responsive switch without restoring focus, and do not let a background scroll region interfere with access to the panel.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Complete and cancel the task without ever dragging the drawer.
- Open a text field on a phone-sized viewport and confirm the active input and actions stay reachable.
- Change viewport size while open and verify one named dialog surface remains active.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.