Skip to content

Actions & Overlays

Dropdown Menu

A button-triggered menu following the WAI-ARIA menu pattern.

stableEnhancer: enhanceDropdownBuilt on <button> + <ul>hydrateless/dropdown.css

A button-triggered menu following the WAI-ARIA menu pattern. The enhancer adds keyboard navigation, typeahead, viewport-aware placement, and aria-expanded/role wiring.

Dropdown

Open with click or , then navigate with the arrow keys and typeahead.

Live

JavaScript

This component ships an optional enhancer. With auto-init it loads automatically; to wire it yourself, import it directly:

import { enhanceDropdown } from '@hydrateless/enhancers/dropdown';

const handle = enhanceDropdown(container, { defaultOpen, onOpenChange, onSelect });
// handle.api  -> imperative controls
// handle.destroy()  -> tear everything down

Props

The framework bindings expose these props (and forward the rest to the root element).

PropTypeDefaultDescription
onSelect(value: string) => voidFires with the selected item value.
defaultOpenbooleanfalseOpen on mount.

Events and callbacks

Event / CallbackPayloadDescription
hl:select{ value: string }Cancelable CustomEvent carrying the item's `data-hl-value` (or text).

CSS variables

Override these on any ancestor to theme the component. See the theme studio to preview changes live.

CSS variableUsed for
--hl-surfaceMenu background.
--hl-borderMenu border.
--hl-shadow-mdMenu elevation.

Accessibility

  • The trigger exposes aria-haspopup and aria-expanded; the list is role="menu".
  • Arrow keys, Home/End, typeahead, and Esc to close are all handled.

Released under the MIT License.