Progress
Shows how much of a task is done with a horizontal bar.
zb:progress zubazar/ui · free (MIT)
Basic usage
Give a percentage from 0 to 100 with value; label is not shown and is read by screen readers.
<div class="space-y-1.5">
<div class="flex justify-between text-sm">
<span class="font-medium text-ink">Sales target</span>
<span class="tabular-nums">68%</span>
</div>
<zb:progress :value="68" label="Sales target" />
</div>
| Prop | Values |
|---|---|
value | 0 – 100 (percent) |
label | Screen reader label |
Size and color
Pick the thickness with size and the color with color; to change the color by fill level, choose it on the server (e.g. danger above 90%).
<zb:progress :value="60" size="md" color="primary" />
<zb:progress :value="60" size="md" color="success" />
<zb:progress :value="60" size="md" color="info" />
<zb:progress :value="60" size="md" color="warning" />
<zb:progress :value="60" size="md" color="danger" />
<zb:progress :value="60" size="md" color="secondary" />
<zb:progress :value="60" size="md" color="dark" />
<zb:progress :value="60" size="sm" color="primary" />
<zb:progress :value="60" size="sm" color="success" />
<zb:progress :value="60" size="sm" color="info" />
<zb:progress :value="60" size="sm" color="warning" />
<zb:progress :value="60" size="sm" color="danger" />
<zb:progress :value="60" size="sm" color="secondary" />
<zb:progress :value="60" size="sm" color="dark" />
<zb:progress :value="60" size="lg" color="primary" />
<zb:progress :value="60" size="lg" color="success" />
<zb:progress :value="60" size="lg" color="info" />
<zb:progress :value="60" size="lg" color="warning" />
<zb:progress :value="60" size="lg" color="danger" />
<zb:progress :value="60" size="lg" color="secondary" />
<zb:progress :value="60" size="lg" color="dark" />
| Prop | Values |
|---|---|
size | sm | md | lg |
color | primary | secondary | success | danger | warning | info | dark |
Striped and animated
striped adds diagonal stripes to the filled part, and animated moves them to show that the work is ongoing.
<div class="space-y-4">
<zb:progress :value="45" size="lg" striped />
<zb:progress :value="80" size="lg" animated />
</div>
| Prop | Values |
|---|---|
striped | true | false |
animated | true | false (turns on the stripes as well) |
With Alpine
alpine takes an Alpine expression; the bar follows its value without a page reload.
<div class="space-y-3" x-data="{ percent: 30 }">
<zb:progress alpine="percent" label="Import" />
<div class="flex items-center gap-2">
<zb:button variant="white" size="sm" x-on:click="percent = Math.max(0, percent - 10)">−10</zb:button>
<zb:button variant="white" size="sm" x-on:click="percent = Math.min(100, percent + 10)">+10</zb:button>
<span class="text-sm tabular-nums" x-text="percent + '%'"></span>
</div>
</div>
| Prop | Values |
|---|---|
alpine | Alpine expression (e.g. percent, file.progress) |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
value | — | null | 0 – 100; clamped and converted to an integer |
alpine | — | null | Alpine expression; when given, it is used instead of value |
label | — | null | Screen reader label; when empty, "Progress" (in the app language) |
size | — | md | sm · md · lg |
color | — | primary | primary · secondary · success · danger · warning · info · dark; variant does the same |
striped | boolean | false | Diagonal stripes |
animated | boolean | false | Moving stripes (turns on striped as well) |
Advanced
File upload progress
Livewire emits the livewire-upload-progress event while uploading a file. Write the percentage from the event to an Alpine variable and bind it to the bar with alpine.
<div x-data="{ upload: 0 }"
x-on:livewire-upload-start="upload = 0"
x-on:livewire-upload-progress="upload = $event.detail.progress">
<input type="file" wire:model="document">
<zb:progress alpine="upload" label="Uploading the document" class="mt-2" />
</div>
Developer notes
- A value given with
alpineis not clamped; keeping it between 0 and 100 is up to you. The bar width andaria-valuenowfollow the expression. - For users who prefer reduced motion,
animatedstripes stop moving.