SaladUI.RadioGroup (SaladUI v1.0.0)

Copy Markdown View Source

Implementation of radio group component from https://ui.shadcn.com/docs/components/radio-group

Examples:

<.radio_group
  name="subscription"
  default-value="monthly"
  on-value-changed={JS.push("plan_changed")}
  aria-label="Subscription"
>
  <div class="flex flex-col space-y-2">
    <div class="flex items-center space-x-2">
      <.radio_group_item value="monthly" id="monthly" />
      <.label for="monthly">Monthly</.label>
    </div>
    <div class="flex items-center space-x-2">
      <.radio_group_item value="yearly" id="yearly" />
      <.label for="yearly">Yearly</.label>
    </div>
  </div>
</.radio_group>

Component events

  • :on-value-changed - Maps the value-changed event. Fired when the selected item changes.

Server commands

Radio group does not support SaladUI.LiveView.send_command/4. To change the selected value from the server, update the value assign and let LiveView re-render.

Summary

Functions

Radio group component that allows selection of one option from a set.

Individual radio button in a radio group.

Functions

radio_group(assigns)

Radio group component that allows selection of one option from a set.

Component events

  • :on-value-changed - Fired when the selected item changes.

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • value (:any) - The current value of the radio group. Defaults to nil.
  • default-value (:any) - The default value of the radio group. Defaults to nil.
  • on-value-changed (:any) - Handler for value changed event. Defaults to nil.
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

radio_group_item(assigns)

Individual radio button in a radio group.

Attributes

  • id (:string) (required)
  • value (:string) (required)
  • disabled (:boolean) - Defaults to false.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.