0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Accessible dropdown menus (APG menu button) and navigation disclosures with keyboard navigation, focus management, and RTL-aware positioning.
Overview
The <drop-down> component provides an accessible dropdown menu for actions, following the WAI-ARIA menu button pattern: arrow keys, Home/End, typeahead, Escape, click-outside-to-close, and the menu roles. For site navigation, add hover to switch to the disclosure pattern instead.
Menu position relative to the trigger. start/end are logical, so they mirror in RTL
hover
boolean
—
Navigation disclosure: no menu roles, links stay in the Tab order, a <button aria-expanded> toggles the list (generated next to a link trigger). Opens on mouse hover or toggle activation, not on focus
no-flip
boolean
—
Keep the requested position instead of flipping to the opposite side when the menu overflows the viewport
open (reflected)
boolean
—
Reflected state — set by open()/close()/toggle() methods, not intended as initial markup
Required Structure
Element
Required
Description
<button data-trigger> or <a data-trigger>
yes
Trigger element that opens the menu. Action mode: aria-haspopup="menu" + aria-expanded. Navigation mode: a link trigger stays a plain link
<button data-dropdown-toggle>
yes
Navigation mode with a link trigger: the submenu toggle (aria-expanded, aria-controls). Generated with aria-label "<link text> submenu" when absent; author one to set your own label
<menu>
yes
Menu container with <li> items holding <button> or <a> actions. Only rows whose nearest menu is this one belong to it (nested drop-downs keep their own)
Marks the element that opens the menu. Falls back to the first direct <button> if absent.
data-disabled
button, a
boolean
Disabled item: aria-disabled="true", stays in the arrow-key order, cannot be activated
data-value
button, a
string
Value reported in drop-down:select detail.value and the items property
Keyboard Navigation
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
Printable characters
Typeahead: move to the next item whose label starts with the typed text (repeat a letter to cycle)
Tab
Close menu and move focus to next element
Items marked data-disabled get aria-disabled="true": they stay in the arrow-key order (so screen reader users learn they exist) but cannot be activated. A native disabled button cannot take focus and is skipped.
Navigation Menus
Add hover for menus of links in a site header. This follows the WAI-ARIA disclosure navigation pattern rather than the menu pattern: the list stays a plain list of links in the normal Tab order, with no menu roles.
When the trigger is a link, it keeps navigating. A small <button data-dropdown-toggle> with aria-expanded is generated next to it to open the list, so keyboard and touch users can still reach the submenu. Author your own <button data-dropdown-toggle aria-label="…"> to set the label (the default is “<link text> submenu”).
When the trigger is a <button>, it is the toggle.
The list opens on mouse hover or when the toggle is activated (click, Enter, Space). Tabbing across the navigation does not open anything.
Escape closes it and returns focus to the toggle; moving focus or clicking outside closes it.
Control menu alignment with the positionattribute. start and end are logical, so bottom-start hangs from the trigger’s right edge in a right-to-left page. When the menu would overflow the viewport it flips to the other side; add no-flip to keep the requested position.
Menu items can be links instead of buttons for navigation.
JavaScript API
Control the dropdown programmatically:
Dropdown JavaScript API
12345678910111213141516171819202122
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');});dropdown.addEventListener('drop-down:select', (e) => {console.log('Selected', e.detail.value, e.detail.item);});
Items as data
Read the menu with items, or assign an array to rebuild it. Entries with href render as links, the rest as <button type="button">; value becomes data-value and is reported in drop-down:select; disabled renders a focusable, non-activatable item. Assigning fires drop-down:items-changed.