v0.0.2
Demos (demo panel, opens in a new tab)

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

Basic usage: view
BLADE

Give the options with options as value => text; label gives screen readers the group's name.

blade
<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>
PropValues
optionsvalue => text
labelThe group's name for screen readers
sizesm · md

Full width

Full width: view
BLADE

full-width shares the container's width equally between the segments; handy in narrow cards and on phones.

blade
<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?

PropTypeDefaultDescription
options—[]value => text
name—nullThe field name; without it, the wire:model / x-model name
value—nullThe chosen value (without a binding)
label—nullThe group's name for screen readers
size—mdsm · md
full-widthbooleanfalseThe segments share the width equally

Developer notes

Events, hooks and details
  • It is built on native radio buttons: it submits with the form, binds with wire:model and the arrow keys move between options.
  • Use name and value in a classic form and wire:model in Livewire.
Zubazar UI · ZubazarDesigned for people.