Navigation
Tab
Tabs that switch between panels of content on the same page: a row (or column) of tab buttons, and one visible panel at a time. The selected tab can be bound to Livewire or Alpine.
Nothing to show
Three tabs over a panel. Profile starts selected and its panel is shown; clicking Billing, or moving to it with the arrow keys, shows the billing panel instead. A tab and a panel are paired by name.
Bound to Livewire #
The group opens on the tab named by $section, and selecting another tab sets it, e.g. to 'team'. Without a bound value (null or ''), selected on a tab picks the initial one; without either, the first tab, and its name is written back to $section.
Nothing to show
Styles and orientation #
segmented puts the tabs in a gray pill with the selected one raised in white; line underlines the selected tab; pills makes rounded tabs, filled when selected. vertical stacks the tabs in a column beside the panels, moved with the up and down arrows.
Nothing to show
Sizes #
size goes from xs to 3xl and is inherited by the tabs.
Nothing to show
Icons, disabled and selected #
Tabs take the element props (icon, suffix...); disabled skips a tab and selected picks the initial one.
Nothing to show
Bound to Alpine #
x-model binds the selected tab to Alpine state, so other controls can switch it.
Nothing to show
Events and data #
Tabs built with @foreach; changed fires on the group with the name of the new tab, here calling a Livewire action.
$48,210
Sales this month
1,240
Orders this month
312
Customers this month
Nothing to show
Customization #
Classes go to each tag; scrollable: reaches the scrollable wrapper around the tab list.
Nothing to show
Reference
tk:tab.group
├── tk:tab.tabs
│ └── tk:tab ...
└── tk:tab.panels
└── tk:tab.panel ...
tk:tab.group
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string | boxed | line, pills, segmented, or the default tabs with a border joining the selected one to the panel. Inherited by the tabs. |
orientation |
string | horizontal |
vertical stacks the tabs in a column. |
selectFirst |
bool | true |
Selects the first tab when nothing else is selected. false starts with no panel shown. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Inherited by the tabs. |
wire:model and x-model bind the name of the selected tab.
Slots
| Slot | Description |
|---|---|
| default | The tabs and the panels. |
Events
| Event | Detail | When |
|---|---|---|
changed |
{ name } |
The user selected another tab. Dispatched on the group; does not bubble. |
tk:tab
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | generated | Pairs the tab with the panel of the same name, and is the bound value. |
label |
string | slot | null |
The tab text, translated. |
badge |
string | slot | null |
A badge after the label. |
selected |
bool | false |
Selects the tab at first, when there is no bound value. |
Also accepts the element props (icon, suffix...) and disabled, which skips the tab.
Slots
| Slot | Description |
|---|---|
| default | The tab content, in place of label. |
tk:tab.panel
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | null |
The tab it belongs to. |
selected |
bool | false |
Shows the panel before the script starts, to avoid a flash of the wrong one, and selects its tab when no tab has selected and there is no bound value. |
tk:tab.tabs takes size, variant and orientation from the group; tk:tab.panels only wraps its children.
Slots
| Slot | Description |
|---|---|
| default | The panel content. |
tk:tab.tabs
Slots
| Slot | Description |
|---|---|
| default | The tabs. |
Prefixes
| Prefix | Goes to |
|---|---|
scrollable: |
The scrollable wrapper around the tab list. |
tk:tab.panels
Slots
| Slot | Description |
|---|---|
| default | The panels. |
Events
Nothing to show
Customization
Classes and attributes on each tag go to its element. tk:tab.tabs is inside a horizontally scrollable wrapper, reached with scrollable:.
Nothing to show
Accessibility
Follows the WAI-ARIA tabs pattern with automatic activation: role="tablist" with aria-orientation, tabs with role="tab", aria-selected and aria-controls, and panels with role="tabpanel" labelled by their tab. Only the selected tab is in the tab order, and the selected panel is focusable.
| Key | Action |
|---|---|
| Arrow Right / Arrow Left | Moves to and selects the next / previous tab, wrapping around and skipping disabled ones. Reversed in right-to-left pages. |
| Arrow Down / Arrow Up | The same, with orientation="vertical". |
| Home / End | Moves to and selects the first / last tab. |
| Tab | Moves from the selected tab into its panel. |
Behavior notes
- Do not set
idon a tab or a panel: the ids are generated fromnameto link them, and a custom one breaks the link. - The group has
wire:ignore.self: a Livewire update keeps the selected tab. - Nested tab groups are independent: the keys and the selection of one do not reach the other.