Drawer
Typed modal edge panel opened imperatively via kuiDrawer(), not rendered as a bound component instance. Built on Angular CDK Overlay. Use it for secondary workflows that keep page context visible: filters, detail panels, edit forms, navigation panels, and mobile action sheets.
Import the inject-function factory and drawer-host contract types from the published package entrypoint.
import {
KUI_DRAWER_CONTEXT,
KuiButton,
KuiDrawerContext,
KuiDrawerHost,
kuiDrawer,
} from '@kikita-labs/ui';
// Import runtime styles once, application-wide:
import '@kikita-labs/ui/styles';Implement KuiDrawerHost on your drawer component, inject KUI_DRAWER_CONTEXT to read data and close, then create a typed opener with kuiDrawer() and call it with data to open. The returned observable emits the typed result once and completes.
<div class="basic-drawer-example">
<button kuiButton type="button" (click)="edit()">Edit item</button>
@if (lastResult()) {
<p class="basic-drawer-example__result">Last result: {{ lastResult() }}</p>
}
</div>side selects the edge the drawer docks to and enters from: right (default), left, bottom, or top. Left/right drawers size by width; top/bottom drawers size by height.
<div class="drawer-sides-example">
@for (side of sides; track side) {
<button kuiButton type="button" shape="outline" (click)="open(side)">{{ side }}</button>
}
</div>size selects a width preset for left/right drawers and a height preset for top/bottom drawers: sm, md (default), lg, full, or auto. auto sizes the panel to its content (min 320px width for left/right, min 200px height for top/bottom).
<div class="drawer-sizes-example">
@for (size of sizes; track size) {
<button kuiButton type="button" shape="outline" (click)="open(size)">{{ size }}</button>
}
</div>Set defaults.drawer once for the application or for a subtree. Each option resolves as local input > defaults.drawer.<option> > built-in default.
import { provideKikitaUi } from '@kikita-labs/ui';
export const appConfig: ApplicationConfig = {
providers: [
provideKikitaUi({
defaults: {
drawer: {
/* options below */
},
},
}),
],
};| Name | Type | Default | Description |
|---|---|---|---|
| closable | boolean | — | Shows the close button in the header. |
| side | 'right' | 'left' | 'bottom' | 'top' | — | Edge the drawer slides in from. |
| size | 'sm' | 'md' | 'lg' | 'full' | 'auto' | — | Drawer size preset. |
| closeOnBackdropClick | boolean | — | Closes the drawer on a backdrop click. |
| closeOnEscape | boolean | — | Closes the drawer on Escape. |
| closeIcon | KuiIconGlyph | — | Icon of the close button. Takes precedence over defaults.icons.close. See Structural Icons. |
Set any of these on the component or an ancestor to restyle one part. Each token is optional: when it is not set, the part uses the role or scale token in the default column.
| Name | Type | Default | Description |
|---|---|---|---|
| --kui-drawer-color | CSS custom property | --kui-color-text | Color |
| --kui-drawer-title-color | CSS custom property | --kui-color-text | Title color |
| --kui-drawer-subtitle-color | CSS custom property | --kui-color-text-secondary | Subtitle color |
| --kui-drawer-close-color | CSS custom property | --kui-color-text-secondary | Close color |
| --kui-drawer-close-bg-hover | CSS custom property | --kui-color-state-hover | Close background, hover |
| --kui-drawer-close-color-hover | CSS custom property | --kui-color-text | Close color, hover |
| --kui-drawer-body-color | CSS custom property | --kui-color-text-secondary | Body color |
| Name | Type | Default | Description |
|---|---|---|---|
| --kui-drawer-header-gap | CSS custom property | --kui-space-3 | Header gap |
| --kui-drawer-subtitle-font-size | CSS custom property | --kui-text-sm-size | Subtitle font size |
| --kui-drawer-close-radius | CSS custom property | --kui-radius-sm | Close corner radius |
| --kui-drawer-body-font-size | CSS custom property | --kui-text-sm-size | Body font size |
| --kui-drawer-footer-gap | CSS custom property | --kui-space-2 | Footer gap |
Every text the component owns (accessible names, visible words, announcements) is a typed message with an English default. Override it for the application with provideKikitaUi({ messages }), or for a subtree with provideKuiMessages.
| Name | Type | Default | Description |
|---|---|---|---|
| label | string | — | Accessible name of a drawer that has no title. Default Drawer. |
API, provider defaults (every KuiDrawerConfig field falls back to defaults.drawer) and tokens verified against @kikita-labs/ui v2.0.0 public typings.
| Name | Type | Default | Description |
|---|---|---|---|
| kuiDrawer(component, config?) | (component: Type<TComponent>, config?: Omit<KuiDrawerConfig, "data">) => (data: TData) => Observable<TResult | undefined> | - | Inject-function factory. Call once per injection context to get a typed opener bound to that component. |
| KuiDrawerHost<TResult, TData> | interface | - | Contract your drawer component implements. Requires a drawerContext property injected from KUI_DRAWER_CONTEXT. |
| KUI_DRAWER_CONTEXT | InjectionToken<KuiDrawerContext<TResult, TData>> | - | Injected inside the drawer component to read data and close the drawer. |
| drawerContext.data | TData | - | Data passed via the opener call, e.g. openDrawer(data). |
| drawerContext.side | KuiDrawerSide | - | Drawer side resolved from KuiDrawerConfig.side, read-only. |
| drawerContext.size | KuiDrawerSize | - | Drawer size preset resolved from KuiDrawerConfig.size, read-only. |
| drawerContext.closable | boolean | - | Mirrors KuiDrawerConfig.closable. Informational only -- the container renders .kui-drawer-close itself when true. |
| drawerContext.close(result?) | (result?: TResult) => void | - | Closes the drawer, optionally emitting a typed result to the opener subscription. |
| KuiDrawerConfig.data | TData | undefined | Available on the low-level config type; kuiDrawer() passes feature data through the returned opener function instead. |
| KuiDrawerConfig.side | 'right' | 'left' | 'bottom' | 'top' | 'right' | Edge from which the drawer enters and docks. |
| KuiDrawerConfig.size | 'sm' | 'md' | 'lg' | 'full' | 'auto' | 'md' | Width for left/right drawers, height for top/bottom drawers. 'auto' sizes to content (min 320px width for left/right, min 200px height for top/bottom). |
| KuiDrawerConfig.closeOnBackdropClick | boolean | true | Closes the drawer on backdrop click. Disable for required actions. |
| KuiDrawerConfig.closeOnEscape | boolean | true | Closes the drawer on Escape. Disable for required actions. |
| KuiDrawerConfig.closable | boolean | true | Shows the .kui-drawer-close button the container renders automatically, absolutely positioned top-right of the panel. |
| KuiDrawerRef<TResult> | class | - | Return type of kuiDrawer(component, config). Calling it with data opens the drawer and returns Observable<TResult | undefined>. |
| .kui-drawer-header / .kui-drawer-title / .kui-drawer-subtitle | CSS classes | - | Header structure classes. .kui-drawer-title is wired as aria-labelledby automatically when present. |
| .kui-drawer-body / .kui-drawer-footer | CSS classes | - | Scrollable content region and action row classes. |
| --kui-drawer-bg | CSS custom property | - | Panel background color. |
| --kui-drawer-border | CSS custom property | - | Panel border color. |
| --kui-drawer-radius | CSS custom property | - | Panel corner radius. |
| --kui-drawer-backdrop-bg | CSS custom property | - | Backdrop fill color. |
| --kui-drawer-width-sm / -md / -lg | CSS custom properties | - | Width presets used by left/right drawers. |
| --kui-drawer-height-sm / -md / -lg | CSS custom properties | - | Height presets used by top/bottom drawers. |
| --kui-drawer-duration-open / -close | CSS custom properties | - | Enter/exit animation durations. |
| KuiDrawerOptions / KuiModalSurfaceOptions | interfaces | - | Shape of defaults.drawer (closable, side, size, closeOnBackdropClick, closeOnEscape, closeIcon), built on the base interface shared with the dialog. Options are read each time a drawer opens. |
Drawer traps focus and matches native modal expectations while docked to a viewport edge.
- The panel renders
role="dialog"andaria-modal="true"automatically. .kui-drawer-titleis wired asaria-labelledbyautomatically when present in your content. Always include one.- Focus is trapped inside the drawer while open and returns to the opener on close.
- Escape closes by default unless
closeOnEscape: false; backdrop click closes by default unlesscloseOnBackdropClick: false. Disable both for required actions. - Backdrop dismissal only applies when the pointer interaction starts on the backdrop; selecting text or dragging from inside the drawer cannot close it accidentally.
- The panel renders
.kui-drawer-closeitself, top-right of the header, whenclosableistrue(the default); the header reserves space for it automatically.drawerContext.closableis retained for informational use only.
Consumer-visible changes of @kikita-labs/ui 2.0 for Drawer.
- The imports are
KuiButtonand the rest of the renamed classes;ng update @kikita-labs/uirenames them.KuiDrawerContext,KUI_DRAWER_CONTEXTandkuiDrawer()keep their names. - Defaults come from
defaults.drawerand are read each time a drawer opens; the close icon takes precedence overdefaults.icons.close. - The backdrop and layers follow the new scrim and layer tokens, the close button reserves its space for titles rendered through a component portal, and the accessible name comes from the
drawermessages.