Skip to content
Focsd homeFocsd homeFocsd
Forms

Drawer / sheet

A modal panel that slides in from an edge.

  • Tag: focsd-drawer
  • Pattern: Dialog (modal, edge)
  • Category: Overlays

Example

Open settings Done
HTML
<focsd-button commandfor="drawer-demo" command="show-modal">Open settings</focsd-button>
<focsd-drawer id="drawer-demo" headline="Workspace settings">
<focsd-text-field label="Workspace name" value="Northwind"></focsd-text-field>
<focsd-button slot="actions" data-dialog-close value="done" variant="action"
>Done</focsd-button
>
</focsd-drawer>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/components/focsd-drawer.js';
</script>
<focsd-drawer headline="Workspace settings">…</focsd-drawer>

API

Attributes

AttributePropertyTypeDefault
placementplacement'end' | 'start' | 'bottom'end
headlineheadlinestring—
openopenbooleanfalse
closedbyclosedBy'any' | 'closerequest' | 'none'closerequest
no-closenoClosebooleanfalse

Methods

MethodDescription
show(opener)Open as a modal dialog. Focus returns to opener (default: the element focused now) on close, which matters in Safari where clicking a button does not focus it.
showModal(opener)Same as show(): Focsd dialogs are always modal.
requestClose(returnValue)Ask to close: fires a cancelable cancel, then closes with returnValue unless it was canceled.
close(returnValue)Close, optionally setting returnValue.

Events

EventDescription
cancelFired before a close request (Escape, backdrop, requestClose); cancel it to keep the dialog open.
closeFired after the dialog closes; read returnValue for how it closed.

Slots

SlotDescription
(default)Default content.
actionsThe dialog's buttons.

CSS parts

Style the inside of the component with ::part(), for example focsd-drawer::part(actions).

PartDescription
actionsThe actions element.
bodyThe body element.
closeThe close (×) button, last in the tab order; it asks to close like Escape (hidden with `no-close`).
dialogThe dialog element.
headlineThe headline element.

Accessibility

  • showModal(), requestClose() and closedby work as on focsd-dialog.
  • A modal dialog anchored to end (default), start or bottom, with the same focus behavior as focsd-dialog, including its close (×) button (no-close hides it).
  • The slide animation is off under reduced motion.

Keyboard

KeyAction
EscapeCloses