plushie/widget/text

Text widget builder.

Types

Option type for text properties.

pub type Opt {
  Size(Float)
  Color(color.Color)
  Font(font.Font)
  Width(length.Length)
  Height(length.Length)
  LineHeight(line_height.LineHeight)
  AlignX(alignment.Alignment)
  AlignY(alignment.Alignment)
  Wrapping(wrapping.Wrapping)
  Ellipsis(String)
  TextDirection(text_direction.TextDirection)
  Shaping(shaping.Shaping)
  Style(TextStyle)
  A11y(a11y.A11y)
}

Constructors

pub opaque type Text
pub type TextStyle {
  DefaultStyle
  PrimaryStyle
  SecondaryStyle
  SuccessStyle
  DangerStyle
  WarningStyle
  Custom(style_map.StyleMap)
}

Constructors

  • DefaultStyle
  • PrimaryStyle
  • SecondaryStyle
  • SuccessStyle
  • DangerStyle
  • WarningStyle
  • Reusable-design-token style: pass a StyleMap that other widgets may also honor (background, border, shadow, state overrides). Only text_color is currently applied by the text widget itself; other fields are silently ignored for raw text. Wrap text in a container to apply background / border / shadow.

Values

pub fn a11y(text: Text, a: a11y.A11y) -> Text

Set accessibility properties for this widget.

pub fn align_x(text: Text, a: alignment.Alignment) -> Text

Set the horizontal alignment.

pub fn align_y(text: Text, a: alignment.Alignment) -> Text

Set the vertical alignment.

pub fn build(text: Text) -> node.Node

Build the text into a renderable Node.

pub fn color(text: Text, c: color.Color) -> Text

Set the color.

pub fn ellipsis(text: Text, e: String) -> Text

Set the text ellipsis mode.

pub fn font(text: Text, f: font.Font) -> Text

Set the font.

pub fn height(text: Text, h: length.Length) -> Text

Set the height.

pub fn line_height(
  text: Text,
  lh: line_height.LineHeight,
) -> Text

Set the line height.

pub fn line_height_animated(
  text: Text,
  animation: node.PropValue,
) -> Text

Set line_height to an animation descriptor (Transition, Spring, or Sequence). The descriptor must be pre-encoded via its module’s encode function.

pub fn new(id: String, content: String) -> Text

Create a new text builder.

pub fn shaping(text: Text, s: shaping.Shaping) -> Text

Set the text shaping strategy.

pub fn size(text: Text, s: Float) -> Text

Set the size.

pub fn size_animated(
  text: Text,
  animation: node.PropValue,
) -> Text

Set size to an animation descriptor (Transition, Spring, or Sequence). The descriptor must be pre-encoded via its module’s encode function.

pub fn style(text: Text, s: TextStyle) -> Text

Set the style.

pub fn text_direction(
  text: Text,
  direction: text_direction.TextDirection,
) -> Text

Set the text direction used by logical text alignment.

pub fn width(text: Text, w: length.Length) -> Text

Set the width.

pub fn with_opts(text: Text, opts: List(Opt)) -> Text

Apply a list of options to a text builder.

pub fn wrapping(text: Text, w: wrapping.Wrapping) -> Text

Set the text wrapping mode.

Search Document