← All Components
<mth-drawer>
Top-layer sliding sheet overlay wrapping native <dialog> with logical edge placements, focus trapping, and exit/enter transitions.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Slide-over drawer supporting start, end, top, and bottom logical placements.
Ready · interact with <mth-drawer>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/drawer"></script>
<mth-drawer placement="end" size="sm">Example</mth-drawer>import '@methane-ui/ui/drawer';
import '@methane-ui/react';
export function Example() {
return <mth-drawer placement="end" size="sm">Example</mth-drawer>;
}<script setup lang="ts">
import '@methane-ui/ui/drawer';
</script>
<template>
<mth-drawer placement="end" size="sm">Example</mth-drawer>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/drawer';
import { MthDrawerDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthDrawerDirective],
template: `<mth-drawer placement="end" size="sm">Example</mth-drawer>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/drawer';
import MthDrawer from '@methane-ui/svelte/MthDrawer.svelte';
</script>
<MthDrawer placement="end" size="sm">Example</MthDrawer>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
open | open | boolean | false | Controls open visibility of the drawer. |
placement | placement | 'end' | 'start' | 'top' | 'bottom' | "end" | Logical edge from which the drawer slides (end | start | top | bottom). |
size | size | 'sm' | 'md' | 'lg' | 'full' | "md" | Drawer dimension preset (sm | md | lg | full). |
label | label | string | "" | Accessible drawer title rendered in the header. |
dismissible | dismissible | boolean | true | Allows dismissing via Escape key, backdrop click, and close button. |
modal | modal | boolean | true | Opens in top-layer modal mode with backdrop and focus trap when true. |
forceFallback | force-fallback | boolean | false | Forces non-top-layer fallback positioning even when native top-layer is supported. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-open | void | Cancelable event fired before opening the drawer. |
mth-after-open | void | Fired once the entry transition completes. |
mth-close | { reason: string } | Cancelable event fired before closing the drawer. |
mth-after-close | { reason: string } | Fired once exit transition completes and focus restores. |
mth-cancel | { reason: string } | Cancelable event fired when dismissed via Escape or backdrop click. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Escape | both | open and dismissible is true | emits mth-cancel, dismisses drawer, and restores focus |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="host". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 1 APG keyboard transitions across LTR/RTL. | mth-drawer.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(open), :state(modal). | Conformance suite |
| i18n | Routes 1 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |