Toddy.Iced.Widget.Radio (Toddy v0.3.0)

Copy Markdown View Source

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.

Summary

Functions

Sets accessibility annotations.

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

Sets the label font.

Sets the radio group identifier.

Sets the radio label text.

Sets the label line height.

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

Sets the radio button size in pixels.

Sets the spacing between radio and label.

Sets the radio style.

Sets the text shaping strategy.

Sets the label text size in pixels.

Sets the radio width.

Applies keyword options to an existing radio struct.

Sets the text wrapping mode.

Types

option()

@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()

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

t()

@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
}

Functions

a11y(r, a11y)

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

Sets accessibility annotations.

build(r)

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

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

font(r, font)

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

Sets the label font.

group(r, group)

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

Sets the radio group identifier.

label(r, label)

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

Sets the radio label text.

line_height(r, line_height)

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

Sets the label line height.

new(id, value, selected, opts \\ [])

@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(r, size)

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

Sets the radio button size in pixels.

spacing(r, spacing)

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

Sets the spacing between radio and label.

style(r, style)

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

Sets the radio style.

text_shaping(r, text_shaping)

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

Sets the text shaping strategy.

text_size(r, text_size)

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

Sets the label text size in pixels.

width(r, width)

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

Sets the radio width.

with_options(r, opts)

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

Applies keyword options to an existing radio struct.

wrapping(r, wrapping)

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

Sets the text wrapping mode.