ProgressBar
color × variant solid/soft/gradient · size sm–xl · active · indeterminate · shine · label · progress_stack
A progress bar with color, variant, size, label and animated states; progress_stack stacks segments.
Filling up
<div class="max-w-[480px]"><.progress value={100} color="primary" bar_class="animate-[mo-fillw_5s_cubic-bezier(.4,0,.2,1)_infinite]" /></div>
color × variant
<div class="grid grid-cols-[70px_repeat(7,minmax(0,1fr))] items-center gap-x-3 gap-y-2.5"> <span></span> <span :for={c <- ~w(neutral primary secondary info success warning error)} class="text-center font-mono text-xs text-muted">{c}</span> <%= for v <- ~w(solid soft gradient) do %> <span class="font-mono text-xs text-muted">{v}</span> <div :for={{c, i} <- Enum.with_index(~w(neutral primary secondary info success warning error))} class="flex min-w-0 justify-center"><.progress value={40 + i * 8} color={c} variant={v} class="w-full" /></div> <% end %> </div>
size
<div class="flex flex-col gap-2.5"> <.progress value={68} color="primary" size="sm" /> <.progress value={68} color="primary" size="md" /> <.progress value={68} color="primary" size="lg" /> <.progress value={68} color="primary" size="xl" label="68%" /> </div>
indeterminate
<.progress indeterminate color="primary" />
active (stripes)
<.progress value={60} color="primary" active />
progress_stack
<.progress_stack> <:segment value={52.6} /> <:segment value={26.6} /> <:segment value={20.8} color="c5" /> </.progress_stack>
ring
<div class="flex flex-wrap items-center gap-2.5"> <.progress_ring value={64} /> <.progress_ring value={92} /> </div>
API values that complete the parity
<div class="grid grid-cols-6 gap-3.5"> <div :for={h <- ~w(1.5 3 4)} class="flex flex-col items-start gap-1.5"><.progress value={60} height={h} color="primary" class="w-full" /><span class="font-mono text-[11px] text-muted">height={h}</span></div> <div class="flex flex-col items-start gap-1.5"> <div class="w-full rounded-[10px] bg-inverse p-2.5"><.progress value={60} color="white" height="1.5" /></div> <span class="font-mono text-[11px] text-muted">color=white</span> </div> <div :for={s <- ~w(md lg)} class="flex flex-col items-start gap-1.5"><.progress value={40} size={s} color="primary" class="w-full" /><span class="font-mono text-[11px] text-muted">size={s}</span></div> </div>
Usage
<.progress value={64} color="primary" /> <.progress value={92} size="xl" label="92%" /> <.progress indeterminate /> <.progress_stack><:segment value={52} color="primary" />…</.progress_stack>
Rules
activeanimates stripes;indeterminateruns without a value;shinepasses a glint.size="xl"fits the label inside the bar.
API reference
Todos os function components, atributos, valores e slots que este componente cobre.
Progress bar (progress/1) and the stacked bar of parts of a total (progress_stack/1). Styled
only with Tailwind utilities (the colour enters as --c/--c-on, see LedgerUI.Color).
<.progress value={64} color="primary" />
<.progress value={92} size="xl" label="92%" />
<.progress indeterminate color="info" />
<.progress_stack label="Sales by channel">
<:segment value={46} label="Counter" />
<:segment value={33} label="Online" />
</.progress_stack>
<.progress_ring value={64} />
variant and size default to the solid, 8px bar. label is the accessible name
(role="progressbar", with aria-valuenow); with size="xl" it is drawn inside the bar
instead. active runs stripes over the bar, indeterminate slides it, with shine it is a
light that passes; loop fills the bar and empties it again (mo-fillw, CSS only).
<.progress>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
value |
:any |
0 |
A number between 0 and max. |
max |
:any |
100 |
|
color |
:string |
"neutral" |
neutral, primary, secondary, info, success, warning, error, white |
variant |
:string |
nil |
nil, solid, soft, gradient |
size |
:string |
nil |
nil, sm, md, lg, xl |
height |
:string |
nil |
nil, `,1,1.5,2,3,4` |
active |
:boolean |
false |
|
indeterminate |
:boolean |
false |
|
shine |
:boolean |
false |
|
loop |
:boolean |
false |
The canvas loop (mo-fillw): the bar fills up to value, then empties, forever (demos). |
label |
:string |
nil |
|
class |
:any |
nil |
|
bar_class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
<.progress_stack>
| Attr | Type | Default | Values / notes |
|---|---|---|---|
max |
:any |
100 |
|
label |
:string |
nil |
|
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
Slots:
<:segment>(required) - attrs:value,color,label
<.progress_bar>
Same as progress/1 (same attributes and slots), under the name the design vitrine uses.
| Attr | Type | Default | Values / notes |
|---|---|---|---|
value |
:any |
0 |
A number between 0 and max. |
max |
:any |
100 |
|
color |
:string |
"neutral" |
neutral, primary, secondary, info, success, warning, error, white |
variant |
:string |
nil |
nil, solid, soft, gradient |
size |
:string |
nil |
nil, sm, md, lg, xl |
height |
:string |
nil |
nil, `,1,1.5,2,3,4` |
active |
:boolean |
false |
|
indeterminate |
:boolean |
false |
|
shine |
:boolean |
false |
|
loop |
:boolean |
false |
|
label |
:string |
nil |
|
class |
:any |
nil |
|
bar_class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.
<.progress_ring>
Circular progress: a conic arc around a hole with the value in the centre.
<.progress_ring value={64} />
<.progress_ring value={3} max={4} label="3/4" color="success" size="lg" />
| Attr | Type | Default | Values / notes |
|---|---|---|---|
value |
:any |
0 |
A number between 0 and max. |
max |
:any |
100 |
|
size |
:string |
"md" |
sm, md, lg - Ring diameter: 40, 56 or 72px. |
color |
:string |
nil |
nil, neutral, primary, secondary, info, success, warning, error, white - Colour of the arc; nil is the accent. |
label |
:string |
nil |
Text in the centre. Defaults to the percentage; "" leaves the centre empty. |
class |
:any |
nil |
Any other HTML/phx attribute goes to the root element.