Sparkline
Minimal line with a gradient and an end point with a halo · draws in a loop
A trend mini-chart with no axes for KPIs and table rows.
color neutral · primary
<span class="text-xs text-muted">As duas cores abaixo usam a mesma linha; neutral em `ink`, primary em teal.</span> <div class="flex flex-wrap items-center gap-2.5" style="gap:16px;margin-top:12px"> <div class="flex w-[300px] items-center gap-4 rounded-lg border border-line bg-panel px-3.5 py-3"> <div class="flex flex-col gap-0.5"><span class="text-xs text-muted">MRR</span><b class="text-xl tabular-nums">$184k</b></div> <.sparkline id="spark-mrr" color="primary" class="h-[46px] min-w-0 flex-1" values={[120, 124, 123, 131, 129, 138, 142, 150, 149, 158, 166, 170, 184]} /> </div> <div class="flex w-[300px] items-center gap-4 rounded-lg border border-line bg-panel px-3.5 py-3"> <div class="flex flex-col gap-0.5"><span class="text-xs text-muted">Clientes</span><b class="text-xl tabular-nums">1.096</b></div> <.sparkline id="spark-clients" class="h-[46px] min-w-0 flex-1" values={[900, 920, 915, 950, 980, 1001, 1020, 1050, 1080, 1096]} /> </div> </div>
Usage
<.sparkline values={@series} />
Rules
- No axes or labels; the number next to it tells the story.
- Motion: the line is drawn, the bars grow from the base, the ring turns into place and the cells light up row by row; loops in both themes.
API reference
Todos os function components, atributos, valores e slots que este componente cobre.
The canvas's sparkline: a line with a soft fill under it, drawn on the server from a list of numbers (the highest at the top), so it renders without JavaScript. Styled only with Tailwind utilities; the line draws in once on mount (the area fades in, the end dot pops).
<.sparkline id="bb" values={[8, 12, 9, 14, 11, 16]} />
<.sparkline id="itau" values={@balances} color="primary" />
color="primary" draws it in the accent, neutral (default) in the ink. The SVG stretches to
the width of its box (preserveAspectRatio="none"); the box gets its size from class/style.
variant="backdrop" is the faded panel at the right of a kpi_card (it positions itself
absolutely inside the card body). id names the gradient of the fill and must be unique on the page.
<.sparkline>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
id (required) |
:string |
Names the gradient of the fill, so it must be unique. | |
values (required) |
:list |
Numbers for the line. | |
color |
:string |
"neutral" |
neutral, primary |
variant |
:string |
"inline" |
inline, backdrop |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.