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

Copy Markdown View Source

Toggler -- on/off switch.

Props

  • is_toggled (boolean) -- whether the toggler is on. Default: false.
  • label (string) -- text label displayed next to the toggler.
  • spacing (number) -- space between toggler and label in pixels.
  • width (length) -- widget width. Default: shrink. See Toddy.Iced.Length.
  • size (number) -- toggler 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 (atom) -- text shaping: :basic, :advanced, or :auto. See Toddy.Iced.Shaping.
  • wrapping (atom) -- text wrapping: :none, :word, :glyph, :word_or_glyph. See Toddy.Iced.Wrapping.
  • text_alignment (atom) -- horizontal label alignment: :left, :center, :right. See Toddy.Iced.Alignment.
  • style (atom) -- named style. Currently only :default.
  • disabled (boolean) -- when true, the toggler 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 toggler struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets whether the toggler is disabled.

Sets the label font.

Sets the toggler label.

Sets the label line height.

Creates a new toggler struct with the given toggle state and optional keyword opts.

Sets the toggler size in pixels.

Sets the spacing between toggler and label.

Sets the toggler style.

Sets the horizontal label text alignment.

Sets the text shaping strategy.

Sets the label text size in pixels.

Sets the toggler width.

Applies keyword options to an existing toggler struct.

Sets the text wrapping mode.

Types

option()

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

style()

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

t()

@type t() :: %Toddy.Iced.Widget.Toggler{
  a11y: Toddy.Iced.A11y.t() | nil,
  disabled: boolean() | nil,
  font: Toddy.Iced.Font.t() | nil,
  id: String.t(),
  is_toggled: boolean(),
  label: String.t() | nil,
  line_height: number() | map() | nil,
  size: number() | nil,
  spacing: number() | nil,
  style: style() | nil,
  text_alignment: Toddy.Iced.Alignment.t() | 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(tg, a11y)

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

Sets accessibility annotations.

build(tg)

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

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

disabled(tg, disabled)

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

Sets whether the toggler is disabled.

font(tg, font)

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

Sets the label font.

label(tg, label)

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

Sets the toggler label.

line_height(tg, line_height)

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

Sets the label line height.

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

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

Creates a new toggler struct with the given toggle state and optional keyword opts.

size(tg, size)

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

Sets the toggler size in pixels.

spacing(tg, spacing)

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

Sets the spacing between toggler and label.

style(tg, style)

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

Sets the toggler style.

text_alignment(tg, text_alignment)

@spec text_alignment(toggler :: t(), text_alignment :: Toddy.Iced.Alignment.t()) ::
  t()

Sets the horizontal label text alignment.

text_shaping(tg, text_shaping)

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

Sets the text shaping strategy.

text_size(tg, text_size)

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

Sets the label text size in pixels.

width(tg, width)

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

Sets the toggler width.

with_options(tg, opts)

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

Applies keyword options to an existing toggler struct.

wrapping(tg, wrapping)

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

Sets the text wrapping mode.