Segmented control
A control that shows a few options side by side to choose one, such as a period, a view or a mode.
zb:segmented zubazar/ui · free (MIT)
Basic usage
BLADE
Give the options with options as value => text; label gives screen readers the group's name.
<div class="flex flex-wrap items-center gap-4">
<zb:segmented name="period" value="week" label="Period" :options="['day' => 'Day', 'week' => 'Week', 'month' => 'Month', 'year' => 'Year']" />
<zb:segmented name="view" value="list" label="View" size="sm" :options="['cards' => 'Cards', 'list' => 'List']" />
</div>
| Prop | Values |
|---|---|
options | value => text |
label | The group's name for screen readers |
size | sm · md |
Full width
BLADE
full-width shares the container's width equally between the segments; handy in narrow cards and on phones.
<zb:segmented name="delivery" value="shipping" label="Delivery" full-width :options="['shipping' => 'Shipping', 'store' => 'Store pickup']" />
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
options | — | [] | value => text |
name | — | null | The field name; without it, the wire:model / x-model name |
value | — | null | The chosen value (without a binding) |
label | — | null | The group's name for screen readers |
size | — | md | sm · md |
full-width | boolean | false | The segments share the width equally |
Developer notes
- It is built on native radio buttons: it submits with the form, binds with
wire:modeland the arrow keys move between options. - Use
nameandvaluein a classic form andwire:modelin Livewire.