Segmented
A two-or-three-way pick over a radiogroup with a springy thumb — like the monthly/yearly billing cycle.
Real scenarios
The component as it is used in a product — not a specimen grid.
The plan’s billing cycle, re-priced as you pick
Two segments over one radiogroup: the thumb springs to the checked radio and, because the radios are native, the arrow keys roam the group while the screen reader reads it under its label. wire:model.live re-renders the price line — the yearly pick spells out its two free months.
Every month: 490,000 tomans · switch to yearly anytime
The sales report’s range picker
size="sm" for a toolbar corner and tone="accent" so the thumb carries the brand colour. The 90-day option arrives disabled with its reason — it belongs to the Business plan — instead of vanishing; the stats row beneath follows the pick live, in the locale’s digits.
A disabled segment keeps its place and fades — the keyboard skips it and the screen reader announces it as dimmed, so the locked door stays visible.
The storefront’s layout switch
The icon-carrying face of the control: grid or list, each segment drawing its glyph from the core icon set. wire:model.live swaps the real product list below — the tiles become rows without leaving the page.
The same two-way pick drives the file manager’s grid|list corner — with two or three options the segmented control beats a select: every choice stays one glance away, and the thumb’s spring tells you it landed.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| options | array | [] | ['month' => 'Monthly'] or ['key' => ['label' => …, 'icon' => …, 'disabled' => …]] — the key becomes the radio’s value; a disabled option keeps its place and dims. |
| label | string | null | The group’s accessible name (aria-label on the radiogroup) — required for screen readers; the radios are native, so the arrow keys roam the group. |
| value | string | نخستین گزینه | The active option for the server render; pass the real value beside wire:model so checked comes from the truth. name falls back to the wire:model path. |
| size | string | null | sm only — shorter and tighter, for a toolbar corner or table rows. |
| tone | string | null | accent: the thumb fills with the brand colour and the checked label stays light; the default is a surface thumb with normal text. |
| wire:model | string | — | The active option binds to Livewire; with .live the pick reaches the server as it happens and the thumb follows along. |
Snippet
{{-- دورهٔ پرداخت: دو گزینه، قیمت زنده --}}
<x-nx::segmented label="دورهٔ پرداخت"
:options="['monthly' => 'ماهانه', 'yearly' => 'سالانه']"
:value="$state['cycle']" wire:model.live="state.cycle" />
{{-- چیدمان کالاها: آیکوندار، برای نوار ابزار --}}
<x-nx::segmented size="sm" tone="accent" label="چیدمان کالاها"
:options="[
'grid' => ['label' => 'شبکهای', 'icon' => 'grid'],
'list' => ['label' => 'فهرستی', 'icon' => 'menu'],
]"
:value="$state['view']" wire:model.live="state.view" />