plushie/widget/rich_text
Rich text widget builder. Displays individually styled spans.
Spans are encoded as a “spans” prop (list of maps), not as child nodes. Each span carries its own text content and optional style overrides.
Types
Option type for rich text properties.
pub type Opt {
Spans(List(Span))
Width(length.Length)
Height(length.Length)
Size(Float)
Font(font.Font)
Color(color.Color)
LineHeight(line_height.LineHeight)
Wrapping(wrapping.Wrapping)
Ellipsis(String)
A11y(a11y.A11y)
}
Constructors
-
Spans(List(Span)) -
Width(length.Length) -
Height(length.Length) -
Size(Float) -
Font(font.Font) -
Color(color.Color) -
LineHeight(line_height.LineHeight) -
Wrapping(wrapping.Wrapping) -
Ellipsis(String) -
A11y(a11y.A11y)
A single styled span within a rich text widget.
pub type Span {
Span(
text: String,
size: option.Option(Float),
font: option.Option(font.Font),
color: option.Option(color.Color),
line_height: option.Option(line_height.LineHeight),
link: option.Option(String),
underline: option.Option(Bool),
strikethrough: option.Option(Bool),
padding: option.Option(padding.Padding),
highlight: option.Option(SpanHighlight),
)
}
Constructors
-
Span( text: String, size: option.Option(Float), font: option.Option(font.Font), color: option.Option(color.Color), line_height: option.Option(line_height.LineHeight), link: option.Option(String), underline: option.Option(Bool), strikethrough: option.Option(Bool), padding: option.Option(padding.Padding), highlight: option.Option(SpanHighlight), )
Highlight behind a span’s text: an optional fill colour and an optional border around the text box.
pub type SpanHighlight {
SpanHighlight(
background: option.Option(color.Color),
border: option.Option(border.Border),
)
}
Constructors
-
SpanHighlight( background: option.Option(color.Color), border: option.Option(border.Border), )
Values
pub fn line_height(
rt: RichText,
lh: line_height.LineHeight,
) -> RichText
Set the line height.
pub fn span(text: String) -> Span
Create a span with the given text and no style overrides.
pub fn span_highlight(s: Span, h: SpanHighlight) -> Span
Set the highlight on a span.
pub fn span_line_height(
s: Span,
lh: line_height.LineHeight,
) -> Span
Set the line height on a span.
pub fn span_padding(s: Span, p: padding.Padding) -> Span
Set the padding on a span.
pub fn span_to_prop_value(s: Span) -> node.PropValue
Encode a single span to a PropValue dict.
pub fn with_opts(rt: RichText, opts: List(Opt)) -> RichText
Apply a list of options to a rich text builder.
pub fn wrapping(rt: RichText, w: wrapping.Wrapping) -> RichText
Set the text wrapping mode.