dropdown — menu trigger with link list
Button that toggles a list of links. ARIA-correct (aria-haspopup, aria-expanded, role="menu"), closes on outside click + ESC, full keyboard navigation (arrow keys, Home/End, Enter to follow).
Use it for header utility menus (account, language, …), filter/sort selectors in lists, secondary actions behind a "..." trigger. Don't use it for primary navigation — that should be visible.
Install
npx czg-ui add dropdown
@import 'components/dropdown'; to app.scss, import './components/dropdown'; to app.js.
Requires base, overlay (auto-resolved by CLI).
Parameters
| Param | Type | Default | Notes | |
|---|---|---|---|---|
id | string | — | Unique id (wires trigger ↔ menu) | |
label | string | — | Trigger button text | |
items | array | — | [['label' => '…', 'href' => '/path'], …] | |
align | string | 'start' | start (left edge of trigger) \ | end (right edge) |
Usage
{include /app/components/Dropdown/dropdown.latte,
id => 'lang-switcher',
label => 'CZ',
align => 'end',
items => [
['label' => 'Čeština', 'href' => '/cs'],
['label' => 'English', 'href' => '/en'],
]
}
Keyboard
Enter/Space— toggle menu↑/↓— move focus among itemsHome/End— jump to first / last itemEsc— close, return focus to triggerTab— close, follow native tab order
When NOT to use
- Primary navigation — main nav links should be visible, not hidden
behind a click
- Form selects with multi-select or search — use a real
<select>
or a dedicated combobox component
- More than ~7 items — promote to a full sidebar/sub-menu instead