# `LedgerUI.Components.Stat`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/stat.ex#L1)

Short figures side by side: the label over the number, a divider between them, inside a card, a
sunken strip or a bare row.

    <.stat_group>
      <.stat_item label="Subtotal" value="R$ 3.240" />
      <.stat_item label="Desconto" value="− R$ 120" />
      <.stat_item label="Total" value="R$ 3.120" tone="accent" />
    </.stat_group>

    <.stat_group animated>
      <.stat_item
        icon="wallet"
        label="Faturamento"
        value="R$ 184.320"
        change="12,4%"
        note="vs. outubro"
        sparkline={[0, 3.5, 2.3, 6.1, 5.2, 8.7, 11, 9.8, 13.3, 15.1, 17.7, 22]}
      />
    </.stat_group>

The vitrine names work as aliases: `delta` (`change`), `hint` (`note`), `goal` (`meter`), `spark`
(`sparkline`) and `delta_tone` (`change_tone`, with `good`/`bad`).

`stat_item/1` carries everything a figure can say: a `unit` (`dias`, `un`), a `change` with its
direction (`trend`) and tone (good or bad news), a `note` under the figure, a goal `meter` and a
`sparkline` (a list of numbers). `tone="accent"` highlights the total of a strip and `size="sm"`
sets a word (`Boleto`) instead of a number. `stat_group` draws the `lu-stats` strip: `card` (the
default) frames it, `card={false}` leaves a bare row, `variant="sunken"` fills it with the
sunken background, and `animated` adds the canvas loop (`mo-stats`): the figures rise, the lines
draw and the changes pop in.

# `stat_group`

## Attributes

* `card` (`:boolean`) - Frames the strip; `false` leaves a bare row. Defaults to `true`.
* `variant` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, or `"sunken"`.
* `animated` (`:boolean`) - The canvas loop (`mo-stats`). Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `stat_item`

## Attributes

* `label` (`:string`) (required)
* `value` (`:string`) (required) - The figure, already formatted.
* `unit` (`:string`) - A smaller faint suffix beside the figure. Defaults to `nil`.
* `icon` (`:string`) - An icon name before the label. Defaults to `nil`.
* `tone` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, or `"accent"`.
* `size` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, or `"sm"`.
* `change` (`:string`) - The variation, already formatted (`12,4%`). Defaults to `nil`.
* `trend` (`:string`) - The arrow of `change`. Defaults to `"up"`. Must be one of `"up"`, `"down"`, or `"flat"`.
* `change_tone` (`:string`) - Good (`pos`) or bad (`neg`) news; by default `pos`, or `flat` when `trend` is flat. Defaults to `nil`. Must be one of `nil`, `"pos"`, `"neg"`, or `"flat"`.
* `note` (`:string`) - The faint line under the figure (`vs. outubro`). Defaults to `nil`.
* `meter` (`:integer`) - Goal progress, 0 to 100: draws the bar. Defaults to `nil`.
* `sparkline` (`:list`) - Numbers of a trend (at least two); the last one is the dot. Defaults to `nil`.
* `sparkline_tone` (`:string`) - Defaults to `"acc"`. Must be one of `"acc"`, `"pos"`, or `"mut"`.
* `delta` (`:string`) - Alias of `change`. Defaults to `nil`.
* `hint` (`:string`) - Alias of `note`. Defaults to `nil`.
* `goal` (`:integer`) - Alias of `meter`. Defaults to `nil`.
* `spark` (`:list`) - Alias of `sparkline`. Defaults to `nil`.
* `delta_tone` (`:string`) - Alias of `change_tone`; `good` is `pos` and `bad` is `neg`. Defaults to `nil`. Must be one of `nil`, `"pos"`, `"neg"`, `"flat"`, `"good"`, or `"bad"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

---

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