Navigation Menu
v0.0.10
v0.0.10StableHeadlessStatelessAccessibleJSApache-2.0
Installation
mix mishka.ui.gen.headless navigation_menu
Source
View Source
Parts & data attributes
Each part carries a stable data-part and a structural chelekom-navigation_menu__* class you can target, plus paired-presence state for open/closed transitions and side/align placement.
| Part | data-part | State / ARIA | Purpose |
|---|---|---|---|
| Root | root | data-orientation | Carries the NavigationMenu hook; reads value, delay, orientation, side and align from its data attributes. |
| List / Item | list / item | data-value | The top-level nav list and each of its entries. |
| Link | link | aria-current, data-active | A plain nav item (no dropdown), used for label + href items. |
| Trigger / Icon | trigger / icon | aria-haspopup, aria-expanded, aria-controls, data-popup-open, data-value, data-open | The button that opens a dropdown, and its caret icon. |
| Content | content | data-activation-direction, data-value | Stored hidden; the active item's content is moved into the viewport and morphed. |
| Positioner / Popup | positioner / popup | data-open, data-closed, data-side, data-align, data-instant | The shared floating surface; exposes --positioner-width/height and --popup-width/height (the morphing size). |
| Viewport / Arrow | viewport / arrow | data-side, data-align | Where the active content lives, and the pointer arrow. |
Accessibility
Base UI's Navigation Menu has no dedicated WAI-ARIA pattern of its own, so this component is built menubar-like, following the WAI-ARIA Menubar pattern. Arrow keys move focus between triggers along the configured orientation, a cross-axis arrow or Enter/Space opens the dropdown, and Escape closes it, restoring focus to the trigger and tabbing out closes it as well.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | Yes | — |
value
|
string
| — | — | No | The open item's value (controlled/initial) |
default_value
|
string
| — | — | No | Initial open item when `open` (uncontrolled) |
open
|
boolean
|
false
| — | No | Force the default_value open on mount |
delay
|
integer
|
50
| — | No | ms to wait before opening on hover |
close_delay
|
integer
|
50
| — | No | ms to wait before closing on leave |
orientation
|
string
|
horizontal
|
horizontalvertical
| No | — |
side
|
string
|
bottom
|
toprightbottomleft
| No | — |
align
|
string
|
center
|
startcenterend
| No | — |
arrow
|
boolean
|
true
| — | No | Render an arrow that points at the active trigger |
class
|
any
| — | — | No | — |
content_class
|
any
| — | — | No | Extra classes for each panel content |
list_class
|
any
| — | — | No | Extra classes for the list part |
item_class
|
any
| — | — | No | Extra classes for each item part |
trigger_class
|
any
| — | — | No | Extra classes for each trigger part |
link_class
|
any
| — | — | No | Extra classes for each plain-link part |
icon_class
|
any
| — | — | No | Extra classes for the trigger icon part |
positioner_class
|
any
| — | — | No | Extra classes for the positioner part |
popup_class
|
any
| — | — | No | Extra classes for the popup part |
viewport_class
|
any
| — | — | No | Extra classes for the viewport part |
arrow_class
|
any
| — | — | No | Extra classes for the arrow part |
rest
|
global
| — | — | No | — |
Slots
| Name | Required | Description |
|---|---|---|
icon
| No | Custom icon rendered inside every dropdown trigger (e.g. a caret svg) |
item
| Yes | A nav item: a link when it has an `href` or no body content, else a dropdown |
Attributes of the item slot
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
label
|
string
| — | — | Yes | — |
href
|
string
| — | — | No | — |
value
|
string
| — | — | No | Stable id for this item (defaults to a generated one) |
active
|
boolean
| — | — | No | Mark a link as the current page (aria-current + data-active) |
content_class
|
any
| — | — | No | Extra classes for this item's panel content (overrides root) |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
navigation_menu
|
--module
| A module name of your own |
What it generates
Functions
navigation_menu
Helpers
None
Generated with it
None
Command
mix mishka.ui.gen.headless navigation_menu