Drawer
A panel that slides in from the left or right edge, for navigation menus, filters and detail views.
<arc-drawer>Overview
Drawer is a panel that slides in from the left or right edge of the viewport, set by position. Use it for a mobile navigation menu, a filter panel or a detail view, without leaving the current page. It has a header with the heading and a close button, and a body that scrolls.
By default it's modal. It's a native <dialog>, so the page behind is inert, dimmed by a backdrop and scroll-locked until it closes. With no-modal it floats over a page that stays usable: no backdrop, no scroll lock, and opening it leaves focus where it was. Escape still closes it while focus is inside.
The close button, Escape and a backdrop click all fire arc-close. The event is cancelable, so preventDefault() keeps the drawer open.
Choose Drawer over Dialog for navigation, for tall content that needs to scroll, or, with no-modal, when people need to keep using the page beside it. For a decision the user has to make before going on, use Dialog.
Guidelines
Do
- Use `position="left"` for navigation menus and `position="right"` for details, filters and settings
- Write a short heading that says what's in the panel
- Listen for `arc-close` and update your own open state
Don't
- Don't use it for critical confirmations. Use Dialog
- Don't put long multi-step forms in it. Use a full page or a Dialog
- Don't open it on page load. Open it when someone asks for it
Features
- 300px wide by default and never more than 85vw, so some of the page always shows
- `heading` is also the panel's accessible name
- The backdrop is `::backdrop`, which can't be a CSS part. Style it with `--drawer-backdrop`
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-button id="open-nav-drawer">Menu</arc-button>
<arc-drawer id="nav-drawer" heading="Navigation" position="left">
<nav style="display:flex; flex-direction:column; gap:4px; padding:8px;">
<a href="/dashboard" style="padding:10px 12px; border-radius:6px; color:var(--text-primary); text-decoration:none;">Dashboard</a>
<a href="/projects" style="padding:10px 12px; border-radius:6px; color:var(--text-secondary); text-decoration:none;">Projects</a>
<a href="/activity" style="padding:10px 12px; border-radius:6px; color:var(--text-secondary); text-decoration:none;">Activity</a>
<a href="/settings" style="padding:10px 12px; border-radius:6px; color:var(--text-secondary); text-decoration:none;">Settings</a>
</nav>
</arc-drawer>
<script>
const openBtn = document.querySelector('#open-nav-drawer');
const drawer = document.querySelector('#nav-drawer');
openBtn.addEventListener('click', () => { drawer.open = true; });
drawer.addEventListener('arc-close', () => { drawer.open = false; });
</script>import { useState } from 'react';
import { Button, Drawer } from '@arclux/arc-ui-react';
function MobileNav() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Menu</Button>
<Drawer open={open} heading="Navigation" position="left" onArcClose={() => setOpen(false)}>
<nav style={{ display: 'flex', flexDirection: 'column', gap: 4, padding: 8 }}>
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</Drawer>
</>
);
}<script setup>
import { ref } from 'vue';
import { Button, Drawer } from '@arclux/arc-ui-vue';
const open = ref(false);
</script>
<template>
<Button @click="open = true">Menu</Button>
<Drawer :open="open" heading="Navigation" position="left" @arc-close="open = false">
<nav style="display:flex; flex-direction:column; gap:4px; padding:8px;">
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</Drawer>
</template><script>
import { Button, Drawer } from '@arclux/arc-ui-svelte';
let open = $state(false);
</script>
<Button onclick={() => open = true}>Menu</Button>
<Drawer {open} heading="Navigation" position="left" on:arc-close={() => open = false}>
<nav style="display:flex; flex-direction:column; gap:4px; padding:8px;">
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</Drawer>import { Component } from '@angular/core';
import { Button, Drawer } from '@arclux/arc-ui-angular';
@Component({
imports: [Button, Drawer],
template: `
<arc-button (click)="open = true">Menu</arc-button>
<arc-drawer [open]="open" heading="Navigation" position="left" (arcClose)="open = false">
<nav style="display:flex; flex-direction:column; gap:4px; padding:8px;">
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</arc-drawer>
`,
})
export class MobileNavComponent {
open = false;
}import { createSignal } from 'solid-js';
import { Button, Drawer } from '@arclux/arc-ui-solid';
function MobileNav() {
const [open, setOpen] = createSignal(false);
return (
<>
<Button onClick={() => setOpen(true)}>Menu</Button>
<Drawer open={open()} heading="Navigation" position="left" onArcClose={() => setOpen(false)}>
<nav style={{ display: 'flex', 'flex-direction': 'column', gap: '4px', padding: '8px' }}>
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</Drawer>
</>
);
}import { useState } from 'preact/hooks';
import { Button, Drawer } from '@arclux/arc-ui-preact';
function MobileNav() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Menu</Button>
<Drawer open={open} heading="Navigation" position="left" onArcClose={() => setOpen(false)}>
<nav style={{ display: 'flex', flexDirection: 'column', gap: 4, padding: 8 }}>
<a href="/dashboard">Dashboard</a>
<a href="/projects">Projects</a>
<a href="/activity">Activity</a>
<a href="/settings">Settings</a>
</nav>
</Drawer>
</>
);
}API
headingstring''- Text displayed in the drawer header bar. Also used as the
aria-labelfor the dialog panel, ensuring screen readers announce the panel purpose when it opens. openbooleanfalse- Controls the visible state of the drawer. Set to
trueto slide the panel into view and activate the backdrop; set tofalseto run the exit animation, remove the backdrop, and restore body scroll. position'left' | 'right''left'- Which edge of the viewport the drawer slides in from. Use
leftfor primary navigation menus andrightfor contextual detail panels, filter sidebars, or settings trays. modalbooleantrue- Whether the drawer blocks the page. On (the default), the page behind is inert, scroll-locked and dimmed until the drawer closes. Off (
no-modal), the drawer floats above a page that stays usable: no backdrop, no scroll lock, and opening it leaves focus where it was. Escape still closes it while focus is inside it.
Events
arc-close- Fired when the drawer closes via backdrop click or escape key
See also
- DialogA modal overlay on the native dialog element, for forms, settings and other content that blocks the page.
- SheetA panel that slides in from the bottom or right edge of the screen over a blurred backdrop.
- SidebarA vertical list of navigation links in grouped sections that can collapse, with the current page highlighted.