# `LedgerUI.Components.Radio`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/radio.ex#L158)

Single choice among visible options: `radio_group/1`, in six forms.

    <.radio_group field={@form[:plan]} options={[{"Free", "free"}, {"Pro", "pro"}]} color="primary" />

    <.radio_group name="basic" value="primary">
      <:radio value="default">Default</:radio>
      <:radio value="error" color="error" disabled>Error</:radio>
    </.radio_group>

    <.radio_group field={@form[:status]} variant="chip" options={[
      %{label: "Todos", value: "all", count: 128}, %{label: "Draft", value: "draft"}]} />

`variant` is `basic`/`outline` (`lu-check` radios), `card` (`lu-choice`, with `control="end"`),
`chip` (`lu-rchip`, `shape="pill"` for round ends), `segmented` (the look of
`LedgerUI.Components.Segmented`, a button per option over a real radio) and `tile` (a 52px
square with free content and an `aria_label`). Every variant keeps a real radio, so the form,
`field` errors, the arrow keys and `phx-change` work; the `on` look follows the radio (hooks
`LedgerUI.ChoiceGroup` and `LedgerUI.Segmented`).

Options are `{label, value}` tuples, plain values, maps with `:label`, `:value`,
`:description`, `:count`, `:icon`, `:color`, `:disabled`, or `:radio` slots.

# `radio`

A radio, or a group of them: with `options` (or `<:radio>` slots) it is `radio_group/1`; without,
one radio with its `label`, `color` and `size`.

    <.radio name="plan" value="pro" label="Pro" checked />
    <.radio field={@form[:plan]} options={[{"Monthly", "m"}, {"Yearly", "y"}]} />

## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `options` (`:list`) - Defaults to `[]`.
* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, or `"error"`.
* `variant` (`:string`) - Defaults to `"basic"`. Must be one of `"basic"`, `"outline"`, `"card"`, `"chip"`, `"segmented"`, or `"tile"`.
* `control` (`:string`) - Defaults to `"start"`. Must be one of `"start"`, or `"end"`.
* `filled` (`:boolean`) - Defaults to `false`.
* `shape` (`:string`) - Defaults to `"circle"`. Must be one of `"circle"`, `"squircle"`, or `"pill"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"xs"`, `"sm"`, `"md"`, or `"lg"`.
* `label` (`:string`) - Defaults to `nil`.
* `label_class` (`:any`) - Defaults to `nil`.
* `label_hint` (`:string`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `wrapper_class` (`:any`) - Defaults to `nil`.
* `radio_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* `checked` (`:boolean`) - A lone radio (no `options`, no `<:radio>`): whether it is the chosen one. Defaults to `false`.
* Global attributes are accepted. Supports all globals plus: `["form", "required"]`.
## Slots

* `radio` - Accepts attributes:

  * `value` (`:any`)
  * `label` (`:string`)
  * `color` (`:string`)
  * `disabled` (`:boolean`)
  * `aria_label` (`:string`)
  * `description` (`:string`)
  * `count` (`:any`)
  * `icon` (`:string`)
  * `class` (`:any`)
  * `style` (`:string`)
  * `checked` (`:boolean`)
  * `shape` (`:string`)
  * `filled` (`:boolean`)

# `radio_choice`

Same as `radio_group/1` (same attributes and slots), under the name the design vitrine uses.
## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `options` (`:list`) - Defaults to `[]`.
* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, or `"error"`.
* `variant` (`:string`) - Defaults to `"basic"`. Must be one of `"basic"`, `"outline"`, `"card"`, `"chip"`, `"segmented"`, or `"tile"`.
* `control` (`:string`) - Defaults to `"start"`. Must be one of `"start"`, or `"end"`.
* `filled` (`:boolean`) - Defaults to `false`.
* `shape` (`:string`) - Defaults to `"circle"`. Must be one of `"circle"`, `"squircle"`, or `"pill"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"xs"`, `"sm"`, `"md"`, or `"lg"`.
* `label` (`:string`) - Defaults to `nil`.
* `label_class` (`:any`) - Defaults to `nil`.
* `label_hint` (`:string`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `wrapper_class` (`:any`) - Defaults to `nil`.
* `radio_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form", "required"]`.
## Slots

* `radio` - Accepts attributes:

  * `value` (`:any`)
  * `label` (`:string`)
  * `color` (`:string`)
  * `disabled` (`:boolean`)
  * `aria_label` (`:string`)
  * `description` (`:string`)
  * `count` (`:any`)
  * `icon` (`:string`)
  * `class` (`:any`)
  * `style` (`:string`)
  * `checked` (`:boolean`)
  * `shape` (`:string`)
  * `filled` (`:boolean`)

# `radio_group`

## Attributes

* `id` (`:string`) - Defaults to `nil`.
* `name` (`:string`) - Defaults to `nil`.
* `value` (`:any`) - Defaults to `nil`.
* `field` (`Phoenix.HTML.FormField`) - Defaults to `nil`.
* `options` (`:list`) - Defaults to `[]`.
* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, or `"error"`.
* `variant` (`:string`) - Defaults to `"basic"`. Must be one of `"basic"`, `"outline"`, `"card"`, `"chip"`, `"segmented"`, or `"tile"`.
* `control` (`:string`) - Defaults to `"start"`. Must be one of `"start"`, or `"end"`.
* `filled` (`:boolean`) - Defaults to `false`.
* `shape` (`:string`) - Defaults to `"circle"`. Must be one of `"circle"`, `"squircle"`, or `"pill"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"xs"`, `"sm"`, `"md"`, or `"lg"`.
* `label` (`:string`) - Defaults to `nil`.
* `label_class` (`:any`) - Defaults to `nil`.
* `label_hint` (`:string`) - Defaults to `nil`.
* `help` (`:string`) - Defaults to `nil`.
* `errors` (`:list`) - Defaults to `[]`.
* `disabled` (`:boolean`) - Defaults to `false`.
* `wrapper_class` (`:any`) - Defaults to `nil`.
* `radio_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["form", "required"]`.
## Slots

* `radio` - Accepts attributes:

  * `value` (`:any`)
  * `label` (`:string`)
  * `color` (`:string`)
  * `disabled` (`:boolean`)
  * `aria_label` (`:string`)
  * `description` (`:string`)
  * `count` (`:any`)
  * `icon` (`:string`)
  * `class` (`:any`)
  * `style` (`:string`)
  * `checked` (`:boolean`)
  * `shape` (`:string`)
  * `filled` (`:boolean`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
