Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

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…

Read the release notes

drop-down

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.

Attributes

AttributeValuesDefaultDescription
position"bottom-start", "bottom-end", "top-start", "top-end"bottom-startMenu position relative to the trigger. start/end are logical, so they mirror in RTL
hoverboolean—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-flipboolean—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

ElementRequiredDescription
<button data-trigger> or <a data-trigger>yesTrigger 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>yesNavigation 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>yesMenu 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)

Child Attributes

AttributeOnValuesDescription
data-triggerbutton | abooleanMarks the element that opens the menu. Falls back to the first direct <button> if absent.
data-disabledbutton, abooleanDisabled item: aria-disabled="true", stays in the arrow-key order, cannot be activated
data-valuebutton, astringValue 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.

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.

Position Variants

Control menu alignment with the position attribute. 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 with Separators

Use role="separator" on empty list items to create visual dividers.

Destructive Actions

Add the danger class to highlight destructive actions.

With Links

Menu items can be links instead of buttons for navigation.

JavaScript API

Control the dropdown programmatically:

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.

Events

Event Detail Fired when
drop-down:open—The menu opens
drop-down:close—The menu closes
drop-down:select{ item, value }One of this menu’s items is activated (not disabled items, and not a nested drop-down’s trigger)
drop-down:items-changed{ items, source }The items property rebuilt the menu

Accessibility

Action menus (default)

  • Trigger has aria-haspopup="menu", aria-expanded and aria-controls
  • Menu has role="menu"; its list items get role="none"
  • Menu items have role="menuitem" and roving focus; disabled items keep focus with aria-disabled="true"
  • Separators have role="separator"
  • Opening from the keyboard focuses the first item (ArrowUp: the last)
  • Keyboard focus shows the theme focus ring, not only a background tint
  • Focus returns to the trigger on Escape or selection
  • Nested drop-downs keep their own items, keys and open state

Navigation menus (hover)

  • No menu roles — links stay links in the Tab order
  • A toggle button carries aria-expanded and aria-controls
  • Focus alone never opens a menu
↑