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

Copy Markdown View Source

Text display -- renders static text.

Props

  • content (string) -- the text string to display.
  • size (number) -- font size in pixels.
  • color (color) -- text color. See Toddy.Iced.Color.
  • font (string | map) -- font specification. See Toddy.Iced.Font.

  • width (length) -- text widget width. See Toddy.Iced.Length.
  • height (length) -- text widget height.
  • line_height (number | map) -- line height. Number is a relative multiplier; map with %{relative: n} or %{absolute: n} for explicit control.

  • align_x (atom) -- horizontal text alignment: :left, :center, :right. See Toddy.Iced.Alignment.
  • align_y (atom) -- vertical text alignment: :top, :center, :bottom. See Toddy.Iced.Alignment.
  • wrapping (atom) -- text wrapping: :none, :word, :glyph, :word_or_glyph. See Toddy.Iced.Wrapping.
  • ellipsis (string) -- text ellipsis mode: "none", "start", "middle", "end". Truncates text that overflows and inserts an ellipsis character at the given position.
  • style (atom) -- named style. One of: :default, :primary, :secondary, :success, :danger, :warning.
  • shaping (atom) -- text shaping strategy: :basic or :advanced. See Toddy.Iced.Shaping.
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Summary

Functions

Sets accessibility annotations.

Sets the horizontal text alignment.

Sets the vertical text alignment.

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

Sets the text color.

Sets the text ellipsis mode. One of: "none", "start", "middle", "end".

Sets the font.

Sets the text widget height.

Sets the line height.

Creates a new text widget struct with the given content and optional keyword opts.

Sets the text shaping strategy.

Sets the font size in pixels.

Sets the text style.

Sets the text widget width.

Applies keyword options to an existing text struct.

Sets the text wrapping mode.

Types

option()

@type option() ::
  {:size, number()}
  | {:color, Toddy.Iced.Color.input()}
  | {:font, Toddy.Iced.Font.t()}
  | {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:line_height, number() | map()}
  | {:align_x, Toddy.Iced.Alignment.t()}
  | {:align_y, Toddy.Iced.Alignment.t()}
  | {:wrapping, Toddy.Iced.Wrapping.t()}
  | {:ellipsis, String.t()}
  | {:shaping, Toddy.Iced.Shaping.t()}
  | {:style, style()}
  | {:a11y, Toddy.Iced.A11y.t()}

preset()

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

style()

@type style() :: preset()

t()

@type t() :: %Toddy.Iced.Widget.Text{
  a11y: Toddy.Iced.A11y.t() | nil,
  align_x: Toddy.Iced.Alignment.t() | nil,
  align_y: Toddy.Iced.Alignment.t() | nil,
  color: Toddy.Iced.Color.t() | nil,
  content: String.t(),
  ellipsis: String.t() | nil,
  font: Toddy.Iced.Font.t() | nil,
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  line_height: number() | map() | nil,
  shaping: Toddy.Iced.Shaping.t() | nil,
  size: number() | nil,
  style: style() | nil,
  width: Toddy.Iced.Length.t() | nil,
  wrapping: Toddy.Iced.Wrapping.t() | nil
}

Functions

a11y(txt, a11y)

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

Sets accessibility annotations.

align_x(txt, align_x)

@spec align_x(text :: t(), align_x :: Toddy.Iced.Alignment.t()) :: t()

Sets the horizontal text alignment.

align_y(txt, align_y)

@spec align_y(text :: t(), align_y :: Toddy.Iced.Alignment.t()) :: t()

Sets the vertical text alignment.

build(txt)

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

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

color(txt, color)

@spec color(text :: t(), color :: Toddy.Iced.Color.input()) :: t()

Sets the text color.

ellipsis(txt, ellipsis)

@spec ellipsis(text :: t(), ellipsis :: String.t()) :: t()

Sets the text ellipsis mode. One of: "none", "start", "middle", "end".

font(txt, font)

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

Sets the font.

height(txt, height)

@spec height(text :: t(), height :: Toddy.Iced.Length.t()) :: t()

Sets the text widget height.

line_height(txt, line_height)

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

Sets the line height.

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

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

Creates a new text widget struct with the given content and optional keyword opts.

shaping(txt, shaping)

@spec shaping(text :: t(), shaping :: Toddy.Iced.Shaping.t()) :: t()

Sets the text shaping strategy.

size(txt, size)

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

Sets the font size in pixels.

style(txt, style)

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

Sets the text style.

width(txt, width)

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

Sets the text widget width.

with_options(txt, opts)

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

Applies keyword options to an existing text struct.

wrapping(txt, wrapping)

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

Sets the text wrapping mode.