# `Toddy.Iced.Widget.RichText`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/rich_text.ex#L1)

Rich text display with individually styled spans.

## Props

- `spans` (list of maps) -- list of span descriptors. Each span is a map with:
  - `text` (string) -- the text content.
  - `size` (number) -- font size in pixels.
  - `color` (color) -- text color. See `Toddy.Iced.Color`.
  - `font` (string | map) -- font specification. See `Toddy.Iced.Font`.
  - `link` (string) -- makes this span a clickable link.
  - `underline` (boolean) -- renders the span with an underline.
  - `strikethrough` (boolean) -- renders the span with a strikethrough line.
  - `line_height` (number) -- relative line height for this span.
  - `padding` (number | map) -- padding around the span. A number applies
    uniformly; a map with `top`, `right`, `bottom`, `left` keys sets per-side.
  - `highlight` (map) -- visual highlight behind the span text. Accepts:
    - `background` (color) -- background color. See `Toddy.Iced.Color`.
    - `border` (map) -- border around the highlight. Accepts `color` (color),
      `width` (number), and `radius` (number or list of 4 numbers).
- `width` (length) -- widget width. Default: shrink. See `Toddy.Iced.Length`.
- `height` (length) -- widget height. Default: shrink.
- `size` (number) -- default font size for all spans.
- `font` (string | map) -- default font for all spans.
- `color` (color) -- default text color for all spans.
- `line_height` (number | map) -- line height.
- `wrapping` -- text wrapping mode. See `Toddy.Iced.Wrapping`.
- `ellipsis` (string) -- text ellipsis mode: `"none"`, `"start"`, `"middle"`, `"end"`.
  Truncates text that overflows and inserts an ellipsis character at the given position.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

## Events

- `%Widget{type: :click, id: "id:link_value"}` -- emitted when a span link is clicked.

# `option`

```elixir
@type option() ::
  {:spans, [map()]}
  | {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:size, number()}
  | {:font, Toddy.Iced.Font.t()}
  | {:color, Toddy.Iced.Color.input()}
  | {:line_height, number() | map()}
  | {:wrapping, Toddy.Iced.Wrapping.t()}
  | {:ellipsis, String.t()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.RichText{
  a11y: Toddy.Iced.A11y.t() | nil,
  color: Toddy.Iced.Color.t() | nil,
  ellipsis: String.t() | nil,
  font: Toddy.Iced.Font.t() | nil,
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  line_height: number() | map() | nil,
  size: number() | nil,
  spans: [map()] | nil,
  width: Toddy.Iced.Length.t() | nil,
  wrapping: Toddy.Iced.Wrapping.t() | nil
}
```

# `a11y`

```elixir
@spec a11y(rich_text :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `build`

```elixir
@spec build(rich_text :: t()) :: Toddy.Iced.ui_node()
```

Converts this rich text struct to a `ui_node()` map via the `Toddy.Iced.Widget` protocol.

# `color`

```elixir
@spec color(rich_text :: t(), color :: Toddy.Iced.Color.input()) :: t()
```

Sets the default text color for all spans.

# `ellipsis`

```elixir
@spec ellipsis(rich_text :: t(), ellipsis :: String.t()) :: t()
```

Sets the text ellipsis mode. One of: `"none"`, `"start"`, `"middle"`, `"end"`.

# `font`

```elixir
@spec font(rich_text :: t(), font :: Toddy.Iced.Font.t()) :: t()
```

Sets the default font for all spans.

# `height`

```elixir
@spec height(rich_text :: t(), height :: Toddy.Iced.Length.t()) :: t()
```

Sets the widget height.

# `line_height`

```elixir
@spec line_height(rich_text :: t(), line_height :: number() | map()) :: t()
```

Sets the line height.

# `new`

```elixir
@spec new(id :: String.t(), opts :: [option()]) :: t()
```

Creates a new rich text struct with optional keyword opts.

# `size`

```elixir
@spec size(rich_text :: t(), size :: number()) :: t()
```

Sets the default font size for all spans.

# `spans`

```elixir
@spec spans(rich_text :: t(), spans :: [map()]) :: t()
```

Sets the list of span descriptors.

# `width`

```elixir
@spec width(rich_text :: t(), width :: Toddy.Iced.Length.t()) :: t()
```

Sets the widget width.

# `with_options`

```elixir
@spec with_options(rich_text :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing rich text struct.

# `wrapping`

```elixir
@spec wrapping(rich_text :: t(), wrapping :: Toddy.Iced.Wrapping.t()) :: t()
```

Sets the text wrapping mode.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
