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

Border radius: uniform or per-corner (top-left, top-right, bottom-right, bottom-left).

pub type BorderRadius {
  UniformRadius(Float)
  PerCornerRadius(Float, Float, Float, Float)
}

Constructors

  • UniformRadius(Float)
  • PerCornerRadius(Float, Float, Float, Float)
pub opaque type RichText

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(Float),
    link: option.Option(String),
    underline: option.Option(Bool),
    strikethrough: option.Option(Bool),
    padding: option.Option(padding.Padding),
    highlight: option.Option(SpanHighlight),
  )
}

Constructors

Highlight behind a span’s text.

pub type SpanHighlight {
  SpanHighlight(
    background: option.Option(color.Color),
    border_color: option.Option(color.Color),
    border_width: option.Option(Float),
    border_radius: option.Option(BorderRadius),
  )
}

Constructors

Values

pub fn a11y(rt: RichText, a: a11y.A11y) -> RichText

Set accessibility properties for this widget.

pub fn build(rt: RichText) -> node.Node

Build the rich text into a renderable Node.

pub fn color(rt: RichText, c: color.Color) -> RichText

Set the color.

pub fn ellipsis(rt: RichText, e: String) -> RichText

Set the text ellipsis mode.

pub fn font(rt: RichText, f: font.Font) -> RichText

Set the font.

pub fn height(rt: RichText, h: length.Length) -> RichText

Set the height.

pub fn line_height(rt: RichText, lh: Float) -> RichText

Set the line height.

pub fn new(id: String) -> RichText

Create a new rich text builder.

pub fn size(rt: RichText, s: Float) -> RichText

Set the size.

pub fn span(text: String) -> Span

Create a span with the given text and no style overrides.

pub fn span_color(s: Span, c: color.Color) -> Span

Set the color on a span.

pub fn span_font(s: Span, f: font.Font) -> Span

Set the font on a span.

pub fn span_highlight(s: Span, h: SpanHighlight) -> Span

Set the highlight on a span.

pub fn span_line_height(s: Span, lh: Float) -> Span

Set the line height on a span.

pub fn span_link(s: Span, url: String) -> Span

Set the link on a span.

pub fn span_padding(s: Span, p: padding.Padding) -> Span

Set the padding on a span.

pub fn span_size(s: Span, size: Float) -> Span

Set the size on a span.

pub fn span_strikethrough(s: Span, st: Bool) -> Span

Set the strikethrough on a span.

pub fn span_to_prop_value(s: Span) -> node.PropValue

Encode a single span to a PropValue dict.

pub fn span_underline(s: Span, u: Bool) -> Span

Set the underline on a span.

pub fn spans(rt: RichText, s: List(Span)) -> RichText

Set the list of styled spans.

pub fn width(rt: RichText, w: length.Length) -> RichText

Set the width.

pub fn wrapping(rt: RichText, w: wrapping.Wrapping) -> RichText

Set the text wrapping mode.

Search Document