Skip to content
Aihio v2.3.0
Search
GitHub
Search Describe what you are building, or name a component, intent, or token. Components and patterns are ranked the way the MCP server's find tool ranks them for an agent.

<aihio-dropdown> v1.2.0 Markdown for agents

Dropdown

A menu of actions or links opened from a trigger button, such as an account menu or a row's More actions. Not for choosing a form value: use aihio-combobox for that.

Intents menu overlay dismissible

Examples

Each one rendered live, over the markup that produces it.

Mistakes

Each one beside its fix, with what aihio lint says about it. The prompt fragment gives agents the same pairs, and the build fails if the linter stops catching one or a fix stops passing.

API

Every attribute, property, method, and event the schema declares for aihio-dropdown.

Attributes

open
boolean default false
Whether the dropdown is open
align
one of startend default start
Alignment of the dropdown content relative to the trigger

Methods

open(options?: { focus?: "first" | "last" | null }): void
Opens the menu in the browser top layer.
close(options?: { restoreFocus?: boolean; reason?: string }): void
Requests that the menu close.
toggle(options?: { focus?: "first" | "last" | null; restoreFocus?: boolean }): void
Toggles the menu.

Events

aihio-open
Fired after the menu opens.
aihio-close
detail { reason: string }
Fired after the menu closes.
aihio-before-close
detail { reason: string } cancelable
Cancelable request fired before the menu closes.

Slots

trigger
The element that opens the dropdown. Must be focusable.
default
Dropdown items and separators.

Composition

Required slots
trigger

Sub-components

Used only inside aihio-dropdown, which gives them their roles and keyboard behaviour.

<aihio-dropdown-item>

A selectable item in the dropdown. Give it a single <a href> child to make it a link.

Attributes

value
string
Item value (defaults to text content)
disabled
boolean default false

Events

aihio-select
detail { value: string }
Fired when the item is selected

<aihio-dropdown-separator>

A visual separator between dropdown items

Accessibility

What you have to provide, and what the component already does. The obligations with a rule are checked by aihio lint and by the dev build's console warnings.

Your obligations

  • error When the trigger is icon-only

    Provide aria-label on the trigger (e.g. aria-label="Open menu").

    Checked as dropdown-trigger-name

Handled for you

  • aria-haspopup="menu" is set on the trigger
  • aria-expanded is toggled on the trigger
  • role="menu" is set on the content panel
  • role="menuitem" is set on each dropdown item — or, when the item's child is <a href>, on that link, which also takes the focus
  • Arrow keys move focus between items; Home/End jump to first/last
  • Typing a character moves to the next item whose label starts with it; a repeated letter cycles through the matches
  • A link item follows itself natively on Enter (so Ctrl/Cmd+Enter and middle-click open a new tab); Space is mapped to it
  • Escape closes and restores focus to the trigger
  • Tab and Shift+Tab close the menu and move on through the page
  • Click outside closes the menu
  • The Popover API provides top-layer rendering where supported; the component handles Escape and outside-pointer dismissal so close requests remain cancelable
  • The menu flips above the trigger and clamps to viewport edges when needed