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

Copy Markdown View Source

Checkbox -- toggleable boolean input.

Props

  • checked (boolean) -- whether the checkbox is checked. Default: false.
  • label (string) -- text label displayed next to the checkbox.
  • spacing (number) -- space between checkbox and label in pixels.
  • width (length) -- widget width. Default: shrink. See Toddy.Iced.Length.
  • size (number) -- checkbox 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 -- named preset (:primary (default), :secondary, :success, :danger) or StyleMap.t(). See Toddy.Iced.StyleMap.
  • icon (map) -- custom icon for the check mark. Map with :code_point (required), and optional :size, :line_height, :font, :shaping.
  • disabled (boolean) -- when true, the checkbox cannot be toggled. Default: false.
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Events

  • %Widget{type: :toggle, id: id, value: bool} -- emitted on toggle, value is the new boolean state.

Summary

Functions

Sets accessibility annotations.

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

Sets whether the checkbox is disabled.

Sets the label font.

Sets a custom icon for the check mark.

Sets the label line height.

Creates a new checkbox struct with the given label, toggle state, and optional keyword opts.

Sets the checkbox size in pixels.

Sets the spacing between checkbox and label.

Sets the checkbox style.

Sets the text shaping strategy.

Sets the label text size in pixels.

Sets the checkbox width.

Applies keyword options to an existing checkbox struct.

Sets the text wrapping mode.

Types

option()

@type option() ::
  {: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()}
  | {:icon, map()}
  | {:disabled, boolean()}
  | {:a11y, Toddy.Iced.A11y.t()}

preset()

@type preset() :: :danger | :success | :secondary | :primary

style()

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

t()

@type t() :: %Toddy.Iced.Widget.Checkbox{
  a11y: Toddy.Iced.A11y.t() | nil,
  disabled: boolean() | nil,
  font: Toddy.Iced.Font.t() | nil,
  icon: map() | nil,
  id: String.t(),
  is_toggled: boolean(),
  label: String.t(),
  line_height: number() | map() | nil,
  size: number() | nil,
  spacing: number() | nil,
  style: style() | nil,
  text_shaping: Toddy.Iced.Shaping.t() | nil,
  text_size: number() | nil,
  width: Toddy.Iced.Length.t() | nil,
  wrapping: Toddy.Iced.Wrapping.t() | nil
}

Functions

a11y(cb, a11y)

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

Sets accessibility annotations.

build(cb)

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

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

disabled(cb, disabled)

@spec disabled(checkbox :: t(), disabled :: boolean()) :: t()

Sets whether the checkbox is disabled.

font(cb, font)

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

Sets the label font.

icon(cb, icon)

@spec icon(checkbox :: t(), icon :: map()) :: t()

Sets a custom icon for the check mark.

line_height(cb, line_height)

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

Sets the label line height.

new(id, label, is_toggled, opts \\ [])

@spec new(
  id :: String.t(),
  label :: String.t(),
  is_toggled :: boolean(),
  opts :: [option()]
) :: t()

Creates a new checkbox struct with the given label, toggle state, and optional keyword opts.

size(cb, size)

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

Sets the checkbox size in pixels.

spacing(cb, spacing)

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

Sets the spacing between checkbox and label.

style(cb, style)

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

Sets the checkbox style.

text_shaping(cb, text_shaping)

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

Sets the text shaping strategy.

text_size(cb, text_size)

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

Sets the label text size in pixels.

width(cb, width)

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

Sets the checkbox width.

with_options(cb, opts)

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

Applies keyword options to an existing checkbox struct.

wrapping(cb, wrapping)

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

Sets the text wrapping mode.