Radio group
NewOverview
A native radio group for selecting one of a set of options.
<div class="example-fields w-full">
<Radio.radio_group
id="example-notification-frequency"
name="notification_frequency"
label="Notification frequency"
description="Choose how often to receive a summary."
value="daily"
>
<:radio value="realtime" label="In real time" />
<:radio value="daily" label="Daily summary" />
<:radio value="weekly" label="Weekly summary" />
</Radio.radio_group>
</div>
Errors
When bound with field, validation errors render beneath the radio group.
<.form
:let={form}
for={
to_form(%{"notification_frequency" => ""},
errors: [notification_frequency: {"can't be blank", []}]
)
}
id="example-radio-group-errors-form"
class="example-fields w-full"
>
<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 | Attributes |
|---|---|---|
radio | Required | value, label, description, checked, disabled |