Skip to content

Drawer

A panel that slides in from an edge of the screen without fully covering what’s behind it. For secondary or long content—filters, a cart, navigation, details—where keeping the context matters. It uses the same <dialog> engine as the Modal.

Overlays · TaishoDS Core, in plain HTML.

Examples

One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.

Filters side panel

html

Not dismissible with its own name

html

Class reference

Every value of each modifier, with its HTML ready to copy.

Side

Which screen edge the panel slides in from. Open each one to see it.

html

Size

The panel’s width (or height, if it slides in from the top or bottom).

html

Combinations

Side and size combined.

html

When to use

  • The content is long, or it helps to keep a sense of where it came from.
  • Filters, navigation, a cart, or a side detail that opens and closes often.
  • On small screens, where an edge-to-edge panel works better than a centered box.

When not to use

  • The task is brief and deserves the screen’s full attention → modal.
  • It’s a yes/no confirmation → alert-dialog.
  • It’s only a menu of actions anchored to a trigger → menu or popover.

Do

  • Choose the side deliberately (side-left, side-right…)—navigation at the start, details and filters at the end (RTL-aware).
  • Give it a header with a title and an explicit close button, in addition to Esc.

Don’t

  • Don’t put the page’s main task in a drawer. If it’s the core work, it belongs on the page.
  • Don’t use it for a passing notice—that’s a toast or a banner.

TaishoDS Core

Doesn’t need our JavaScript—the browser handles it.

It’s a <dialog> with invoker commands (commandfor), with CSS transforms to slide in from the side.

Limitation

The trigger uses invoker commands (`command` and `commandfor`), which browsers ship from Chrome 135, Firefox 144, and Safari 26.2. In older ones, Core’s JS runs the commands on the dialog. If you didn’t load that JS, the button doesn’t open it and you need to call `dialog.showModal()` from your own code.

From the CDN, without a build, load taisho.drawer.css along with taisho.base.css. Also load:

  • taisho.button.css
  • taisho.icon.css
  • taisho.modal.css
  • taisho.spinner.css

For how Core works in general, see Behavior.

Accessibility

Implements the Modal Dialog pattern from the WAI-ARIA APG.

  • Same model as the Modal—a <dialog> opened with showModal(). The browser provides the dialog role, traps focus, makes the background inert, and returns focus to the trigger on close. In WebKit, when the dialog was opened with the mouse, focus does not return to the trigger on close, because Safari does not focus a button on click.
  • Accessible name. With the component’s own title, the <dialog> carries aria-labelledby pointing to it. With a custom header, the name has to come from aria-labelledby (pointing to the header’s title) or aria-label on the <dialog>. With neither (a title attribute also counts as a name), Core warns in the console when the page is served from localhost.
  • Not dismissible: closedby="none" on the <dialog>. The browser doesn’t close it with Esc or the backdrop. Where the browser ignores it, the cancel event and the Esc keystroke are prevented. Only its own buttons close it, and the × button is hidden.
  • While the panel is open, the page behind it doesn’t scroll and keeps the scrollbar’s space (scrollbar-gutter: stable), so the content doesn’t shift.
  • It lives in the top layer, without a portal or z-index. The slide-in comes from @starting-style, based on the side (side-left, side-right, side-top, or side-bottom).

Keyboard

On top of what the browser already does (Tab moves focus, Enter activates a button).

Key What it does
EscCloses the panel. If it isn’t dismissible (closedby="none"), it does nothing, not even on a second Esc in a row.

Verification

What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.

  • axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
  • keyboard Key map documented above, checked against the component.
  • screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.