Welcome to Vanilla Breeze
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
Accessible dropdown menus with keyboard navigation, focus management, and automatic positioning.
The <drop-down> component provides an accessible dropdown menu. It handles all keyboard interactions (arrow keys, Escape, Enter), click-outside-to-close, and proper ARIA attributes.
<drop-down> <button data-trigger>Options</button> <menu> <li><button>Edit</button></li> <li><button>Duplicate</button></li> <li><button>Share</button></li> <li role="separator"></li> <li><button class="danger">Delete</button></li> </menu></drop-down>
| Attribute | Values | Default | Description |
|---|---|---|---|
position | "bottom-start", "bottom-end", "top-start", "top-end" | bottom-start | Menu position relative to trigger |
hover | boolean | — | Open on hover/focus instead of click (useful for nav menus) |
no-flip | boolean | — | Disable automatic flip when menu overflows viewport |
open (reflected) | boolean | — | Reflected state — set by open()/close()/toggle() methods, not intended as initial markup |
| Element | Required | Description |
|---|---|---|
<button data-trigger> or <a data-trigger> | yes | Trigger element that opens the menu |
<menu> | yes | Menu container with <li> items holding <button> or <a> actions |
| Attribute | On | Values | Description |
|---|---|---|---|
data-trigger | button | a | boolean | Marks the element that opens the menu. Falls back to first <button> if absent. |
Full keyboard support following WAI-ARIA menu pattern:
| Key | Action |
|---|---|
| Enter / Space | Open menu (on trigger) or activate item (in menu) |
| ArrowDown | Open menu and focus first item, or move to next item |
| ArrowUp | Open menu and focus last item, or move to previous item |
| Home | Focus first menu item |
| End | Focus last menu item |
| Escape | Close menu and return focus to trigger |
| Tab | Close menu and move focus to next element |
Control menu alignment with the position attribute.
<drop-down position="bottom-end"> <button data-trigger>Bottom End</button> <menu>...</menu></drop-down>
Use role="separator" on empty list items to create visual dividers.
Add the danger class to highlight destructive actions.
<li><button class="danger">Delete permanently</button></li>
Menu items can be links instead of buttons for navigation.
Control the dropdown programmatically:
const dropdown = document.querySelector('drop-down'); // Methodsdropdown.open(); // Open the menudropdown.close(); // Close the menudropdown.toggle(); // Toggle open/closed // Propertiesdropdown.isOpen; // Boolean: current state // Eventsdropdown.addEventListener('drop-down:open', () => { console.log('Menu opened');}); dropdown.addEventListener('drop-down:close', () => { console.log('Menu closed');});
aria-haspopup="menu" and aria-expandedrole="menu"role="menuitem"role="separator"