# `Toddy.Iced.Widget.Radio`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/radio.ex#L1)

Radio button -- one-of-many selection.

All radios in a group should share the same `group` prop value. The
`selected` prop should be set to the currently selected value across
all radios in the group.

## Props

- `value` (string) -- the value this radio represents.
- `selected` (string) -- the currently selected value in the group.
- `label` (string) -- label text. Defaults to `value` if omitted.
- `group` (string) -- group identifier. All radios with the same group
  emit events with the group name as the event ID.
- `spacing` (number) -- space between radio and label in pixels.
- `width` (length) -- widget width. Default: shrink. See `Toddy.Iced.Length`.
- `size` (number) -- radio button size in pixels.
- `text_size` (number) -- label text size in pixels.
- `font` (string | map) -- label font. See `Toddy.Iced.Font`.
- `line_height` (number | map) -- label line height.
- `text_shaping` -- text shaping strategy. See `Toddy.Iced.Shaping`.
- `wrapping` -- text wrapping mode. See `Toddy.Iced.Wrapping`.
- `style` -- `:default` or `StyleMap.t()` for custom styling. See `Toddy.Iced.StyleMap`.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

## Events

- `%Widget{type: :select, id: group_or_id, value: value}` -- emitted when this radio is selected.
  The `id` is the `group` prop if set, otherwise the node ID.

# `option`

```elixir
@type option() ::
  {:label, String.t()}
  | {:group, String.t()}
  | {:spacing, number()}
  | {:width, Toddy.Iced.Length.t()}
  | {:size, number()}
  | {:text_size, number()}
  | {:font, Toddy.Iced.Font.t()}
  | {:line_height, number() | map()}
  | {:text_shaping, Toddy.Iced.Shaping.t()}
  | {:wrapping, Toddy.Iced.Wrapping.t()}
  | {:style, style()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `style`

```elixir
@type style() :: :default | Toddy.Iced.StyleMap.t()
```

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.Radio{
  a11y: Toddy.Iced.A11y.t() | nil,
  font: Toddy.Iced.Font.t() | nil,
  group: String.t() | nil,
  id: String.t(),
  label: String.t() | nil,
  line_height: number() | map() | nil,
  selected: String.t(),
  size: number() | nil,
  spacing: number() | nil,
  style: style() | nil,
  text_shaping: Toddy.Iced.Shaping.t() | nil,
  text_size: number() | nil,
  value: String.t(),
  width: Toddy.Iced.Length.t() | nil,
  wrapping: Toddy.Iced.Wrapping.t() | nil
}
```

# `a11y`

```elixir
@spec a11y(radio :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `build`

```elixir
@spec build(radio :: t()) :: Toddy.Iced.ui_node()
```

Converts this radio struct to a `ui_node()` map via the `Toddy.Iced.Widget` protocol.

# `font`

```elixir
@spec font(radio :: t(), font :: Toddy.Iced.Font.t()) :: t()
```

Sets the label font.

# `group`

```elixir
@spec group(radio :: t(), group :: String.t()) :: t()
```

Sets the radio group identifier.

# `label`

```elixir
@spec label(radio :: t(), label :: String.t()) :: t()
```

Sets the radio label text.

# `line_height`

```elixir
@spec line_height(radio :: t(), line_height :: number() | map()) :: t()
```

Sets the label line height.

# `new`

```elixir
@spec new(
  id :: String.t(),
  value :: String.t(),
  selected :: String.t(),
  opts :: [option()]
) :: t()
```

Creates a new radio struct with the given value, selected state, and optional keyword opts.

# `size`

```elixir
@spec size(radio :: t(), size :: number()) :: t()
```

Sets the radio button size in pixels.

# `spacing`

```elixir
@spec spacing(radio :: t(), spacing :: number()) :: t()
```

Sets the spacing between radio and label.

# `style`

```elixir
@spec style(radio :: t(), style :: style()) :: t()
```

Sets the radio style.

# `text_shaping`

```elixir
@spec text_shaping(radio :: t(), text_shaping :: Toddy.Iced.Shaping.t()) :: t()
```

Sets the text shaping strategy.

# `text_size`

```elixir
@spec text_size(radio :: t(), text_size :: number()) :: t()
```

Sets the label text size in pixels.

# `width`

```elixir
@spec width(radio :: t(), width :: Toddy.Iced.Length.t()) :: t()
```

Sets the radio width.

# `with_options`

```elixir
@spec with_options(radio :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing radio struct.

# `wrapping`

```elixir
@spec wrapping(radio :: t(), wrapping :: Toddy.Iced.Wrapping.t()) :: t()
```

Sets the text wrapping mode.

---

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