Text display, renders static text.
Props
| Name | Type | Default | Description |
|---|---|---|---|
content | String.t() | atom() | required | The text string to display. |
size | number() | nil | Font size in pixels. |
color | String.t() | nil | Text color. |
font | :default | :monospace | String.t() | %Plushie.Type.Font{} | nil | Font specification. |
width | :fill | :shrink | {:fill_portion, pos_integer()} | number() | nil | Text widget width. |
height | :fill | :shrink | {:fill_portion, pos_integer()} | number() | nil | Text widget height. |
line_height | number() | %{relative: number()} | %{absolute: number()} | nil | Line height. Number is a relative multiplier; map with %{relative: n} or %{absolute: n} for explicit control. |
align_x | :left | :center | :right | :top | :bottom | nil | Horizontal text alignment: :left, :center, :right. |
align_y | :left | :center | :right | :top | :bottom | nil | Vertical text alignment: :top, :center, :bottom. |
wrapping | :none | :word | :glyph | :word_or_glyph | nil | Text wrapping: :none, :word, :glyph, :word_or_glyph. |
ellipsis | :none | :start | :middle | :end | nil | Ellipsis mode: :none, :start, :middle, :end. |
shaping | :basic | :advanced | :auto | nil | Text shaping strategy: :basic or :advanced. |
| style | :default \| :primary \| :secondary \| :success \| :danger \| :warning \| :dark \| :weak \| :rounded_box \| term() | nil | Named style: :default, :primary, :secondary, :success, :danger, :warning. |
| event_rate | integer() | nil | Max events per second for coalescable events. |
| a11y | %Plushie.Type.A11y{} \| map() \| keyword() | %{role: :label, label_from: :content} | Accessibility annotations. |
Constructor
Text.new(id, content)
Text.new(id, content, opts)
Summary
Functions
Accessibility annotations.
Horizontal text alignment: :left, :center, :right.
Vertical text alignment: :top, :center, :bottom.
Converts this widget struct to a ui_node() map.
Text color.
The text string to display.
Ellipsis mode: :none, :start, :middle, :end.
Max events per second for coalescable events.
Font specification.
Text widget height.
Line height. Number is a relative multiplier; map with %{relative: n} or %{absolute: n} for explicit control.
Creates a new widget struct with the given positional args and keyword options.
Text shaping strategy: :basic or :advanced.
Font size in pixels.
Named style: :default, :primary, :secondary, :success, :danger, :warning.
Creates a :text widget.
Text widget width.
Applies keyword options to an existing widget struct.
Text wrapping: :none, :word, :glyph, :word_or_glyph.
Types
@type option() :: (((((((((((({:size, number()} | {:color, atom() | String.t() | map()}) | {:font, :default | :monospace | String.t() | %Plushie.Type.Font{ family: term(), stretch: term(), style: term(), weight: term() }}) | {:width, :fill | :shrink | {:fill_portion, pos_integer()} | number()}) | {:height, :fill | :shrink | {:fill_portion, pos_integer()} | number()}) | {:line_height, number() | %{relative: number()} | %{absolute: number()}}) | {:align_x, :left | :center | :right | :top | :bottom}) | {:align_y, :left | :center | :right | :top | :bottom}) | {:wrapping, :none | :word | :glyph | :word_or_glyph}) | {:ellipsis, :none | :start | :middle | :end}) | {:shaping, :basic | :advanced | :auto}) | {:style, :default | :primary | :secondary | :success | :danger | :warning | :dark | :weak | :rounded_box | term()}) | {:event_rate, integer()}) | {:a11y, %Plushie.Type.A11y{ active_descendant: term(), busy: term(), described_by: term(), description: term(), disabled: term(), error_message: term(), expanded: term(), has_popup: term(), hidden: term(), invalid: term(), label: term(), label_from: term(), labelled_by: term(), level: term(), live: term(), mnemonic: term(), modal: term(), orientation: term(), position_in_set: term(), radio_group: term(), read_only: term(), required: term(), role: term(), selected: term(), size_of_set: term(), toggled: term(), value: term() } | map() | keyword()}
@type t() :: %Plushie.Widget.Text{ a11y: (%Plushie.Type.A11y{ active_descendant: term(), busy: term(), described_by: term(), description: term(), disabled: term(), error_message: term(), expanded: term(), has_popup: term(), hidden: term(), invalid: term(), label: term(), label_from: term(), labelled_by: term(), level: term(), live: term(), mnemonic: term(), modal: term(), orientation: term(), position_in_set: term(), radio_group: term(), read_only: term(), required: term(), role: term(), selected: term(), size_of_set: term(), toggled: term(), value: term() } | map() | keyword()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, align_x: (:left | :center | :right | :top | :bottom) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, align_y: (:left | :center | :right | :top | :bottom) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, color: String.t() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, content: (String.t() | atom()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, ellipsis: (:none | :start | :middle | :end) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, event_rate: integer() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, font: (:default | :monospace | String.t() | %Plushie.Type.Font{ family: term(), stretch: term(), style: term(), weight: term() }) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, height: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, id: String.t(), line_height: (number() | %{relative: number()} | %{absolute: number()}) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, shaping: (:basic | :advanced | :auto) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, size: number() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, style: (:default | :primary | :secondary | :success | :danger | :warning | :dark | :weak | :rounded_box | term()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, width: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, wrapping: (:none | :word | :glyph | :word_or_glyph) | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil }
Functions
@spec a11y( widget :: t(), value :: (%Plushie.Type.A11y{ active_descendant: term(), busy: term(), described_by: term(), description: term(), disabled: term(), error_message: term(), expanded: term(), has_popup: term(), hidden: term(), invalid: term(), label: term(), label_from: term(), labelled_by: term(), level: term(), live: term(), mnemonic: term(), modal: term(), orientation: term(), position_in_set: term(), radio_group: term(), read_only: term(), required: term(), role: term(), selected: term(), size_of_set: term(), toggled: term(), value: term() } | map() | keyword()) | nil ) :: t()
Accessibility annotations.
Accepts %Plushie.Type.A11y{} | map() | keyword().
Horizontal text alignment: :left, :center, :right.
Accepts :left | :center | :right | :top | :bottom.
Vertical text alignment: :top, :center, :bottom.
Accepts :left | :center | :right | :top | :bottom.
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
Converts this widget struct to a ui_node() map.
Text color.
Accepts String.t().
The text string to display.
Accepts String.t() | atom().
Ellipsis mode: :none, :start, :middle, :end.
Accepts :none | :start | :middle | :end.
Max events per second for coalescable events.
Accepts integer().
@spec font( widget :: t(), value :: (:default | :monospace | String.t() | %Plushie.Type.Font{ family: term(), stretch: term(), style: term(), weight: term() }) | nil ) :: t()
Font specification.
Accepts :default | :monospace | String.t() | %Plushie.Type.Font{}.
@spec height( widget :: t(), value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil ) :: t()
Text widget height.
Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().
@spec line_height( widget :: t(), value :: (number() | %{relative: number()} | %{absolute: number()}) | nil ) :: t()
Line height. Number is a relative multiplier; map with %{relative: n} or %{absolute: n} for explicit control.
Accepts number() | %{relative: number()} | %{absolute: number()}.
Creates a new widget struct with the given positional args and keyword options.
Arguments
id- unique widget identifiercontent- The text string to display.opts- keyword list of optional props
Text shaping strategy: :basic or :advanced.
Accepts :basic | :advanced | :auto.
Font size in pixels.
Accepts number().
@spec style( widget :: t(), value :: (:default | :primary | :secondary | :success | :danger | :warning | :dark | :weak | :rounded_box | term()) | nil ) :: t()
Named style: :default, :primary, :secondary, :success, :danger, :warning.
Accepts :default | :primary | :secondary | :success | :danger | :warning | :dark | :weak | :rounded_box | term().
Creates a :text widget.
Shorthand for new/2. Import this macro to use the widget name
directly in view functions:
import Plushie.Widget.Text, only: [text: 2]
text("my-id", prop: value)
@spec width( widget :: t(), value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil ) :: t()
Text widget width.
Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().
Applies keyword options to an existing widget struct.
Text wrapping: :none, :word, :glyph, :word_or_glyph.
Accepts :none | :word | :glyph | :word_or_glyph.