# `Macaw.Builtin.Text`
[🔗](https://github.com/dcoai/macaw/blob/v0.6.0/lib/macaw/builtin/text.ex#L1)

The words the built-in components head a field's value with (spec/05 §6): its label
from the source's schema, and its unit as a reader writes it.

A schema posts a unit as its UCUM code (`Cel`, `[mi_i]/h`, `{request}/s`), the machine's
spelling, chosen so units convert exactly. A reader sees its display symbol, with its
annotations (`°C`, `mi/h`, `request/s`): `Macaw.Units.Unit.symbol/2` with
`annotations: true`, since without them `{request}/s` would read `/s` and say less
than the code. A code with no symbol is shown as it is.

# `heading`

```elixir
@spec heading(Macaw.Component.Context.t(), String.t(), String.t()) :: String.t()
```

The heading of `field` of `slot`: its label (`Macaw.Component.Context.label/3`, the
field's name without one), then its unit in parentheses when it has one:
`Request rate (request/s)`.

# `role`

```elixir
@spec role(Macaw.Data.Schema.t() | nil, String.t(), term()) :: String.t()
```

The role `field`'s schema gives a state (macaw_data spec/01 §1.6): a theme's word, `neutral`
for a state with none, for no state, for no schema, and for a word that spells no class. A
theme's own word is kept, as a class it may style. It is `roles/2` of the schema and field
asked of the state.

# `roles`

```elixir
@spec roles(Macaw.Data.Schema.t() | nil, String.t()) :: (term() -&gt; String.t())
```

`role/3` of `field` as a function of the state, its roles read from the schema and judged
once, so a component drawing many states builds them once per render (#408), not once
per state.

# `symbol`

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

The display symbol of a UCUM `code`, annotations kept, or the code itself when
`Macaw.Units.Unit.symbol/2` gives none.

# `unit`

```elixir
@spec unit(Macaw.Component.Context.t(), String.t(), String.t()) :: String.t() | nil
```

The unit `field` of `slot` is shown in: its code's display symbol, the code itself when
it has none, or `nil` for a field without a unit.

# `value`

```elixir
@spec value(term()) :: String.t()
```

A value as a built-in component writes it: a time as ISO 8601, whole seconds without a
fraction; a point as `lon, lat`; `nil` as nothing. A `:term` column's value (#481):
a literal color as its CSS text, a theme's color as its name (`{:color, "good"}` is
`good`), and any other term as Elixir writes it, never a raise.

# `words`

```elixir
@spec words(Macaw.Data.Schema.t() | nil, String.t()) :: (term() -&gt; String.t())
```

`words/3` of `field` as a function of the state, its display names read from the schema
once, so a component drawing many states reads them once per render (#408).

# `words`

```elixir
@spec words(Macaw.Data.Schema.t() | nil, String.t(), term()) :: String.t()
```

A state's words, so color is never the only cue: its display name from the schema, else
its spelling, and an en dash for no state. It is `words/2` of the schema and field asked
of the state.

---

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