<x-widget.radio>
Radio Blade component for Laravel and Livewire
A group of radio buttons in a fieldset, with descriptions and disabled options, or a segmented track for two to four short choices. Works with Livewire wire:model.
php artisan bladewell:add radio
- Works with
- Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
- Guide
- Livewire multi-step form with validation per step
Usage
Livewire
In a Livewire component, bind the group with wire:model (deferred) or wire:model.live: public string $plan = 'free'. No name is needed. The chosen option follows the property after every render, so setting it in PHP changes the choice. The values are strings in the HTML: bind an enum property (public Plan $plan) and Livewire casts it back.
<x-widget.radio
label="Plan"
:options="['free' => 'Free', 'pro' => 'Pro', 'team' => 'Team']"
wire:model.live="plan"
/>
Examples
Radio
Options take the same shapes as the select, plus an optional description. inline lays them out in a row.
Show code Hide code
<div class="grid gap-8 sm:grid-cols-2">
<x-widget.radio name="plan" label="Plan" value="pro" required :options="[
['id' => 'starter', 'name' => 'Starter', 'description' => 'Up to 3 wallets'],
['id' => 'pro', 'name' => 'Pro', 'description' => 'Unlimited wallets and exports'],
['id' => 'team', 'name' => 'Team', 'description' => 'Coming soon', 'disabled' => true],
]" />
<x-widget.radio name="frequency" label="Statement" inline :options="['monthly' => 'Monthly', 'quarterly' => 'Quarterly', 'yearly' => 'Yearly']" value="monthly" />
</div>
Segmented
variant="segmented": the options as one track with the chosen one raised in it, for two to four short choices. Still a radio group: the arrow keys move the choice, it submits with the form, and wire:model binds it as usual.
Show code Hide code
<div class="flex flex-col gap-8">
<x-widget.radio name="billing_cycle" label="Billing" variant="segmented" value="monthly" :options="['monthly' => 'Monthly', 'yearly' => 'Yearly']" />
<x-widget.radio name="view" label="Show" variant="segmented" value="list" :options="[
['id' => 'list', 'name' => 'List'],
['id' => 'board', 'name' => 'Board'],
['id' => 'calendar', 'name' => 'Calendar', 'disabled' => true],
]" />
</div>
Props
Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.
<x-widget.radio>
| Prop | Default | Description |
|---|---|---|
| name |
null
|
What it submits as; its error and old input are found under it. Optional with wire:model, which then names it. |
| id |
null
|
Defaults to one made from the name (or the wire:model property). |
| label |
null
|
The group's legend, read before each option. |
| options |
[]
|
A list, a value => label map, enum cases, or rows (value or id, label or name) with an optional description and disabled. |
| value |
null
|
The chosen value. Old input wins after a failed submit; with wire:model and no value, the bound property. |
| error |
null
|
An error message of your own; otherwise the validation error for the name, from the session or Livewire. |
| info |
null
|
A hint under the field. |
| bag |
'default'
|
Which error bag to read the error from. |
| disabled |
false
|
Greyed out: it can't be changed. |
| readonly |
false
|
Shown, and submitted, but it can't be changed. With disabled, disabled wins. |
| inline |
false
|
Side by side instead of stacked. |
| variant |
'default'
|
default: a round radio beside each label. segmented: the options as one track with the chosen one raised in it, for two to four short choices (always side by side). |
Accessibility
All 2 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.
Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.
Source
What bladewell:add radio writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from
Field, and the theme and base CSS.
resources/views/components/widget/radio/index.blade.php Show
app/View/Widget/ElementIds.php Show
app/View/Widget/FormField.php Show