Rich text display with individually styled spans.
Spans are typed via Plushie.Widget.RichText.Span. Construct them
with span/1 plus chained setters or pass a plain map for ad-hoc
cases. Typed spans are encoded automatically; plain maps fall
through unchanged.
alias Plushie.Widget.RichText.Span
rich_text "status",
spans: [
Span.new("Build ") |> Span.color("#000000"),
Span.new("ok") |> Span.color("#22aa22") |> Span.underline(true)
]Accessibility
Screen readers see individual spans but cannot infer the overall
meaning of the composed text. Set a11y: %{label: "..."} with a
plain-text summary so assistive technology can announce the full
content in one pass:
rich_text "status", spans: spans,
a11y: %{label: "Build succeeded in 3.2 seconds"}For content that updates dynamically, combine label with a live
region annotation so changes are announced automatically:
rich_text "output", spans: spans,
a11y: %{label: summary_text, live: :polite}Props
| Name | Type | Default | Description |
|---|---|---|---|
spans | [map()] | nil | List of span descriptors. Use Plushie.Widget.RichText.Span or plain maps. |
width | :fill | :shrink | {:fill_portion, pos_integer()} | number() | nil | Widget width. Default: shrink. |
height | :fill | :shrink | {:fill_portion, pos_integer()} | number() | nil | Widget height. Default: shrink. |
size | number() | nil | Default font size for all spans. |
font | :default | :monospace | String.t() | %Plushie.Type.Font{} | nil | Default font for all spans. |
color | String.t() | nil | Default text color for all spans. |
line_height | number() | %{relative: number()} | %{absolute: number()} | nil | Line height. Number is relative; map for explicit control. |
wrapping | :none | :word | :glyph | :word_or_glyph | nil | Text wrapping mode. |
ellipsis | :none | :start | :middle | :end | nil | Text ellipsis mode: :none, :start, :middle, :end. |
event_rate | integer() | nil | Max events per second for coalescable events. |
a11y | %Plushie.Type.A11y{} | map() | keyword() | %{role: :label} | Accessibility annotations. |
Summary
Functions
Accessibility annotations.
Converts this widget struct to a ui_node() map.
Default text color for all spans.
Text ellipsis mode: :none, :start, :middle, :end.
Max events per second for coalescable events.
Default font for all spans.
Widget height. Default: shrink.
Line height. Number is relative; map for explicit control.
Creates a new widget struct with the given ID and keyword options.
Creates a :rich_text widget.
Default font size for all spans.
List of span descriptors. Use Plushie.Widget.RichText.Span or plain maps.
Widget width. Default: shrink.
Applies keyword options to an existing widget struct.
Text wrapping mode.
Types
@type option() :: ((((((((({:spans, [map()]} | {:width, :fill | :shrink | {:fill_portion, pos_integer()} | number()}) | {:height, :fill | :shrink | {:fill_portion, pos_integer()} | number()}) | {:size, number()}) | {:font, :default | :monospace | String.t() | %Plushie.Type.Font{ family: term(), stretch: term(), style: term(), weight: term() }}) | {:color, atom() | String.t() | map()}) | {:line_height, number() | %{relative: number()} | %{absolute: number()}}) | {:wrapping, :none | :word | :glyph | :word_or_glyph}) | {:ellipsis, :none | :start | :middle | :end}) | {: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.RichText{ 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, color: String.t() | 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, size: number() | Plushie.Animation.Transition.t() | Plushie.Animation.Spring.t() | Plushie.Animation.Sequence.t() | nil, spans: [map()] | 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().
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
Converts this widget struct to a ui_node() map.
Default text color for all spans.
Accepts String.t().
Text 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()
Default font for all spans.
Accepts :default | :monospace | String.t() | %Plushie.Type.Font{}.
@spec height( widget :: t(), value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil ) :: t()
Widget height. Default: shrink.
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 relative; map for explicit control.
Accepts number() | %{relative: number()} | %{absolute: number()}.
Creates a new widget struct with the given ID and keyword options.
Creates a :rich_text widget.
Shorthand for new/2. Import this macro to use the widget name
directly in view functions:
import Plushie.Widget.RichText, only: [rich_text: 2]
rich_text("my-id", prop: value)
Default font size for all spans.
Accepts number().
List of span descriptors. Use Plushie.Widget.RichText.Span or plain maps.
Accepts [map()].
@spec width( widget :: t(), value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil ) :: t()
Widget width. Default: shrink.
Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().
Applies keyword options to an existing widget struct.
Text wrapping mode.
Accepts :none | :word | :glyph | :word_or_glyph.