Radio group

New

Overview

A native radio group for selecting one of a set of options.

Each option renders a native radio inputs element.

Notification frequency

Choose how often to receive a summary.

HEEx
<.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.

Operating system

Friendly desktop and server distribution with long-term support releases.

A community distribution with a conservative release cycle.

Tracks upstream releases closely for current development tools.

HEEx
<.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 .

Notification frequency

can't be blank

HEEx
<.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

terminal
mix dizzy.add radio_group

Component API

Radio.radio_group

Attributes

Attributes for Radio.radio_group
NameTypeDefault 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

Slots for Radio.radio_group
NameRequired
radio Required

Radio slot attributes

Attributes for the radio slot in Radio.radio_group
NameTypeDefault Values
value :string Requiredโ€”
label :string Requiredโ€”
sublabel :string nilโ€”
description :string nilโ€”
checked :boolean nilโ€”
disabled :boolean nilโ€”

Explore Dizzy