Skip to content

Menu

An accessible dropdown menu with keyboard navigation, typeahead, and zero visual opinion.

Styled with CSS Tailwind

Basic Menu

Click the button or press Space / Enter / arrow keys to open. Use Up / Down to navigate, Home / End to jump, Enter / Space to activate, Escape to close. Type a letter to jump to the first matching item. ARIA wiring (aria-haspopup="menu", aria-expanded, aria-activedescendant) is handled automatically.

Last action: (none)

Disabled Items

Set Disabled="true" on individual items. Disabled items receive data-disabled, are skipped by arrow-key nav, and are ignored by typeahead. The CSS version styles them with a [data-disabled] selector, the Tailwind version with the data-disabled: variant.

Last action: (none)

Rich item content

Items can contain any markup. Use the data-active hook to drive the highlighted style and provide a Label string so typeahead still works when the content is rich.

Last action: (none)

Sections and dividers

Group related items with a plain <div> divider or a section heading. These are regular HTML elements — the menu component doesn't need to know about them.

Last action: (none)

Anchor Positioning

Set Anchor on BitBhMenuItems to automatically position the dropdown relative to the button. The panel uses position: fixed and auto-updates on scroll/resize. It flips to the opposite side if there's not enough space, and shifts to stay within the viewport. CSS custom properties --button-width, --anchor-gap are exposed on the panel — "Match Width" sets the panel's width to --button-width.

Last action: (none)

Polymorphic items

Set As="a" on an item to render it as an anchor tag — useful for navigation links inside a menu. The item still participates in keyboard nav and receives all the ARIA attributes.

Open on hover

OpenOnHover opens the menu when the pointer rests on the button for HoverOpenDelay (here 200 ms) and closes it HoverCloseDelay (here 400 ms) after the pointer has left the button and the menu. The hover leaves the focus where it is - type in the field, hover the button, keep typing. On the button, Enter, Space, ↓ or ↑ moves the focus into the menu; with nothing focused, so does one of the menu's own keys (the arrows, Home / End, Enter, Space). A click on the button keeps the menu open; Escape closes it from anywhere. See the menubar page for site navigation.

Last action: (none)
An unhandled error has occurred. Reload 🗙