Navigation
Nav
A navigation menu of links, in a row for a header or in a column for a sidebar, with the current page highlighted by an indicator that slides from item to item. Items can be grouped under headings, collapsed in expandable groups, or opened as a dropdown.
Nothing to show
Three links in a row, each with its icon; Orders has a "3" badge. The link to the current page (or a page under it) has aria-current="page" and a light background that slides to the clicked link when the user navigates with wire:navigate.
In a sidebar #
A vertical list. "Sales" is a muted heading over its links. "Settings" is a button with a chevron that shows and hides its links, indented with a guide line, open only on the settings pages.
Nothing to show
Indicator styles #
A line under the current item, as in tabs; a line beside it in a vertical list; and no sliding indicator, only a background on the current item.
Nothing to show
A dropdown inside the nav #
"Products" looks like the other items, with a chevron, and opens a tk:menu with its links.
Nothing to show
Items in the slot #
tk:nav.item takes the element props (icon, badge, iconDot...). An item without a label is square, for an icon-only link.
Nothing to show
Line on top #
In a row, line-top draws the line above the current item instead of under it.
Nothing to show
Accent and sizes #
variant="accent" colors the current item with the accent color; size goes from xs to 3xl and is inherited by the items.
Nothing to show
Scrollable #
In a row, scrollable scrolls the items horizontally when they do not fit.
Nothing to show
With Livewire #
Items with action are buttons that switch a section without leaving the page; current follows the bound value. An expandable group fires opened and closed.
Nothing to show
Customization #
Classes go to the <nav>; item: reaches each item from items and indicator: the sliding highlight.
Nothing to show
Reference
tk:nav
├── tk:nav.item
├── tk:nav.group
│ └── tk:nav.item ...
└── tk:nav.menu
└── tk:menu.item ...
tk:nav
| Prop | Type | Default | Description |
|---|---|---|---|
items |
array | Collection | null |
The items, rendered before the slot. Each is an array of tk:nav.item props and attributes. |
label |
string | null |
The accessible name of the <nav>, translated. Give one when the page has more than one nav. |
list |
bool | false |
Lays the items out in a column, for sidebars. |
indicator |
string | false | bg |
The highlight of the current item: bg (a sliding background), line-top or line-bottom (in a row), line-left or line-right (in a list). false highlights with a fixed background, without animation. |
persist |
bool | null |
With Livewire (any value but false), keeps the indicator across wire:navigate page changes (it is @persisted), so it slides to the new page's item. false leaves it out. Inside an element you persist yourself (a persisted tk:sidebar, an @persist block) it is not needed: the indicator drops its own @persist there by itself. Ignored when indicator is false. |
variant |
string | null |
accent colors the current item with the accent color. |
scrollable |
bool | false |
In a row, scrolls horizontally when the items do not fit. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Inherited by the items. |
Slots
| Slot | Description |
|---|---|
| default | The items, after those from items. |
Prefixes
| Prefix | Goes to |
|---|---|
item: |
Each item rendered from items. A value set in the item itself wins; classes are added. |
indicator: |
The sliding indicator. |
tk:nav.item
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string | slot | null |
The link text, translated. |
square |
bool | auto | Equal padding on all sides, for an icon-only item. On by default when there is no label. |
Also accepts the element props (icon, badge, iconDot...) and the link props of Element (href, route, current, exact...). size, variant and indicator are inherited from the nav.
Slots
| Slot | Description |
|---|---|
| default | The link text, in place of label. |
tk:nav.group
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string | null |
The heading of the group. Without it, the group only spaces its items. |
expandable |
bool | false |
Turns the heading into a button that shows and hides the items. Needs a label. |
expanded |
bool | true |
With expandable, whether the group starts open. |
line |
bool | true |
With expandable, indents the items with a guide line. |
collapse |
bool | string | false |
With expandable, animates opening and closing; a string is passed as x-collapse modifiers. |
Slots
| Slot | Description |
|---|---|
| default | The items of the group. |
Events
| Event | Detail | When |
|---|---|---|
opened |
The group was expanded. | |
closed |
The group was collapsed. |
Prefixes
| Prefix | Goes to |
|---|---|
trigger:, line: |
With expandable, the expand button and the guide line. |
container: |
The element around the items, in a group with a label. |
heading: |
The heading of a group with a label that is not expandable. |
tk:nav.menu
Takes the props of tk:nav.item for its button, and items, keepOpen and animation for the tk:menu it opens. :animate="false" keeps the chevron still.
Slots
| Slot | Description |
|---|---|
| default | The menu items, after those from items. |
Prefixes
| Prefix | Goes to |
|---|---|
dropdown:, menu: |
The dropdown and the menu. |
Events
An expandable tk:nav.group dispatches these on its own element; they do not bubble.
Nothing to show
Customization
Classes and attributes on tk:nav go to the <nav>. To reach the parts, prefix the attribute (listed in the Reference above).
Nothing to show
Accessibility
A native <nav> landmark, named by label, with real links. The current page's link has aria-current="page". An expandable group's button has aria-expanded and aria-controls, and the indicator is decorative.
Behavior notes
- With Livewire installed, the indicator is kept across
wire:navigatepage changes (it is@persisted), so it slides from the old page's item to the new one. In a nav you persist yourself (a persisted sidebar), the indicator drops its own@persistwhen it starts, because Livewire cannot put back a persisted element nested in another; it then travels with your persisted element and still slides when the current link changes. No:persist="false"is needed there. The nav is matched between pages by itsid, or by its order among the navs of the page when it has none: give it anidwhen the pages render a different number of navs before it, and always when the nav is inside a Livewire component, whose id is part of the generated key and changes on every page. It does not animate when the user prefers reduced motion. - The indicator moves when the nav or its links change size, the nav scrolls, the window is resized, the current link changes or the page changes with
wire:navigate. Content inserted above the nav that does not change the nav's size (a banner shown by a Livewire update, for instance) leaves the indicator out of place until one of these happens. - An expandable group keeps the state the user left it in across Livewire updates.
- A slot that starts with a
<nav>is rendered as it is, without a second<nav>around it.