Radio group
NewOverview
A native radio group for selecting one of a set of options.
Each option renders a native radio inputs element.
<.form for={@form}>
<Radio.radio_group
field={@form[:notification_frequency]}
label="Notification frequency"
description="Choose how often to receive a summary."
>
<:radio value="realtime" label="In real time" />
<:radio value="daily" label="Daily summary" />
<:radio value="weekly" label="Weekly summary" />
</Radio.radio_group>
</.form>
Per-option detail
Each :radio
slot accepts its own sublabel
and description
for short metadata and supporting detail.
<.form for={@form}>
<Radio.radio_group field={@form[:operating_system]} label="Operating system">
<:radio
value="ubuntu"
label="Ubuntu"
sublabel="Most popular"
description="Friendly desktop and server distribution with long-term support releases."
/>
<:radio
value="debian"
label="Debian"
sublabel="Rock solid"
description="A community distribution with a conservative release cycle."
/>
<:radio
value="fedora"
label="Fedora"
sublabel="Latest packages"
description="Tracks upstream releases closely for current development tools."
/>
</Radio.radio_group>
</.form>
Errors
When bound with field, validation errors render beneath the
radio input elements
.
<.form for={@form}>
<Radio.radio_group field={@form[:notification_frequency]} label="Notification frequency">
<:radio value="realtime" label="In real time" />
<:radio value="daily" label="Daily summary" />
<:radio value="weekly" label="Weekly summary" />
</Radio.radio_group>
</.form>
Add this module
mix dizzy.add radio_group
Component API
Radio.radio_group
Attributes
| Name | Type | Default | Values |
|---|---|---|---|
class |
:any
| nil | โ |
description |
:string
| nil | โ |
disabled |
:boolean
| false | โ |
errors |
:list
| [] | โ |
field |
{:struct, Phoenix.HTML.FormField}
| nil | โ |
id |
:string
| nil | โ |
label |
:string
| nil | โ |
name |
:string
| nil | โ |
required |
:boolean
| false | โ |
rest |
:global
| nil | โ |
value |
:any
| nil | โ |
Slots
| Name | Required |
|---|---|
radio | Required |
Radio slot attributes
| Name | Type | Default | Values |
|---|---|---|---|
value |
:string
| Required | โ |
label |
:string
| Required | โ |
sublabel |
:string
| nil | โ |
description |
:string
| nil | โ |
checked |
:boolean
| nil | โ |
disabled |
:boolean
| nil | โ |