# `Plushie.Widget.RichText.Span`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/widget/rich_text/span.ex#L1)

A typed span for `Plushie.Widget.RichText`.

Each span carries one segment of text with its own optional
styling. Construct one with `new/1` and chain setters, or pass a
plain map (the renderer accepts both):

    alias Plushie.Widget.RichText.Span

    Span.new("Hello ")
    |> Span.color("#003366")
    |> Span.size(18.0)
    |> Span.font(Plushie.Type.Font.new(weight: :bold))

Spans are encoded to the wire as maps with snake_case keys. Unset
fields are omitted so the renderer falls back to the rich_text
widget's default styling for that property.

# `highlight`

```elixir
@type highlight() :: %{
  optional(:background) =&gt; Plushie.Type.Color.t(),
  optional(:border) =&gt; Plushie.Type.Border.t()
}
```

Highlight backdrop drawn behind a span. `background` paints a
solid colour; `border` adds a stroke around the highlighted
region.

# `t`

```elixir
@type t() :: %Plushie.Widget.RichText.Span{
  color: Plushie.Type.Color.t() | nil,
  font: Plushie.Type.Font.t() | nil,
  highlight: highlight() | nil,
  line_height: Plushie.Type.LineHeight.t() | nil,
  link: String.t() | nil,
  padding: Plushie.Type.Padding.t() | nil,
  size: number() | nil,
  strikethrough: boolean() | nil,
  text: String.t(),
  underline: boolean() | nil
}
```

# `color`

```elixir
@spec color(t(), Plushie.Type.Color.input()) :: t()
```

Set the text colour.

# `encode`

```elixir
@spec encode(t() | map()) :: map()
```

Encode a span (or plain map) to its wire form.

# `font`

```elixir
@spec font(t(), Plushie.Type.Font.t()) :: t()
```

Set the font.

# `highlight`

```elixir
@spec highlight(t(), Plushie.Type.Color.input() | highlight()) :: t()
```

Set the highlight backdrop. Accepts a `Plushie.Type.Color`
(background only) or a map with `:background` and/or `:border`.

# `line_height`

```elixir
@spec line_height(t(), Plushie.Type.LineHeight.t() | number() | map()) :: t()
```

Set the line height.

# `link`

```elixir
@spec link(t(), String.t()) :: t()
```

Set a hyperlink URL the renderer emits as `link_click`.

# `new`

```elixir
@spec new(String.t()) :: t()
```

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

# `padding`

```elixir
@spec padding(t(), Plushie.Type.Padding.t() | number() | map() | list()) :: t()
```

Set the padding around the span's text.

# `size`

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

Set the font size (pixels).

# `strikethrough`

```elixir
@spec strikethrough(t(), boolean()) :: t()
```

Toggle the strikethrough decoration.

# `underline`

```elixir
@spec underline(t(), boolean()) :: t()
```

Toggle the underline decoration.

---

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