Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

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 Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Drawer primitives from @/components/kamod-ui/drawer (same surface as shadcn drawer; no Vaul runtime).

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy 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 SetupTypeScript
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.

src/components/DrawerExample.tsx1 line
// See repo drawer-doc.tsx — Drawer + DrawerTrigger asChild + DrawerContent + header/footer

Basic

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 Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Scrollable 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 Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Sides

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 Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Responsive 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 Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props 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.

API reference
Your API, from source

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

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? 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.
@kamod-ch/ui/drawer41.5 KB min · 9.7 KB gzipSignals: via dialog@preact/signals

Drawer

DrawerProps

Drawer documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerProps

Configure children for Drawer. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanDrawerProps

Configure defaultOpen for Drawer. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
direction
DrawerDirectionDrawerProps

Edge the drawer opens from (shadcn/Vaul `direction`). Default `bottom`.

Default
"bottom"
dismissible
booleanDrawerProps

When false, Escape and an overlay click leave the dialog open. An explicit close control still closes it. Default true.

Default
—
lockBodyScroll
booleanDrawerProps

When true, locks document scroll while open (shadcn default).

Default
—
onOpenChange
((open: boolean) => void)DrawerProps

Configure onOpenChange for Drawer. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
open
booleanDrawerProps

Configure open for Drawer. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerClose

DrawerCloseProps

DrawerClose documented props
Prop / typeDescription
asChild
booleanDrawerCloseProps

Configure asChild for DrawerClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
children
ComponentChild[] | ComponentChildDrawerCloseProps

Configure children for DrawerClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDrawerCloseProps

Configure data-slot for DrawerClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerContent

DrawerContentProps

DrawerContent documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerContentProps

Configure children for DrawerContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DrawerContentProps

Configure class for DrawerContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDrawerContentProps

Configure data-slot for DrawerContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
forceMount
booleanDrawerContentProps

Configure forceMount for DrawerContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
showCloseButton
booleanDrawerContentProps

Configure showCloseButton for DrawerContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
showHandle
booleanDrawerContentProps

Drag affordance for top/bottom drawers. Default: `true` when `direction` is top or bottom.

Default
—

DrawerDescription

DrawerDescriptionProps

DrawerDescription documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerDescriptionProps

Configure children for DrawerDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerFooter

DrawerFooterProps

DrawerFooter documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerFooterProps

Configure children for DrawerFooter. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerHeader

DrawerHeaderProps

DrawerHeader documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerHeaderProps

Configure children for DrawerHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerTitle

DrawerTitleProps

DrawerTitle documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDrawerTitleProps

Configure children for DrawerTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DrawerTrigger

DrawerTriggerProps

DrawerTrigger documented props
Prop / typeDescription
asChild
booleanDrawerTriggerProps

Configure asChild for DrawerTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
children
ComponentChild[] | ComponentChildDrawerTriggerProps

Configure children for DrawerTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDrawerTriggerProps

Configure data-slot for DrawerTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

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 fields
DrawerProps
Exported Source Declaration from Drawer.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

Declaration
DrawerCloseProps
Exported Source Declaration from DrawerClose.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 fields
DrawerContentProps
Exported Source Declaration from DrawerContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DrawerContentProps before adapting it.
DrawerDescriptionProps
Exported Source Declaration from DrawerDescription.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

Declaration
DrawerFooterProps
Exported Source Declaration from DrawerFooter.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

Declaration
DrawerHeaderProps
Exported Source Declaration from DrawerHeader.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

Declaration
DrawerTitleProps
Exported Source Declaration from DrawerTitle.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

Declaration
DrawerTriggerProps
Exported Source Declaration from DrawerTrigger.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

Declaration
DrawerDirection
Exported Source Declaration from drawer-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 field
DrawerContextValue
Exported Source Declaration from drawer-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.
Required fields
direction

Accessibility

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.

  1. Complete and cancel the task without ever dragging the drawer.
  2. Open a text field on a phone-sized viewport and confirm the active input and actions stay reachable.
  3. 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.

Take the Next Useful Step

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.