v0.0.2
Demos (demo panel, opens in a new tab)

Progress

Shows how much of a task is done with a horizontal bar.

zb:progress zubazar/ui · free (MIT)

Basic usage

Basic usage: view
BLADE

Give a percentage from 0 to 100 with value; label is not shown and is read by screen readers.

blade
<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>
PropValues
value0 – 100 (percent)
labelScreen reader label

Size and color

Size and color: view
BLADE

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%).

size
color
blade
<zb:progress :value="60" size="md" color="primary" />
blade
<zb:progress :value="60" size="md" color="success" />
blade
<zb:progress :value="60" size="md" color="info" />
blade
<zb:progress :value="60" size="md" color="warning" />
blade
<zb:progress :value="60" size="md" color="danger" />
blade
<zb:progress :value="60" size="md" color="secondary" />
blade
<zb:progress :value="60" size="md" color="dark" />
blade
<zb:progress :value="60" size="sm" color="primary" />
blade
<zb:progress :value="60" size="sm" color="success" />
blade
<zb:progress :value="60" size="sm" color="info" />
blade
<zb:progress :value="60" size="sm" color="warning" />
blade
<zb:progress :value="60" size="sm" color="danger" />
blade
<zb:progress :value="60" size="sm" color="secondary" />
blade
<zb:progress :value="60" size="sm" color="dark" />
blade
<zb:progress :value="60" size="lg" color="primary" />
blade
<zb:progress :value="60" size="lg" color="success" />
blade
<zb:progress :value="60" size="lg" color="info" />
blade
<zb:progress :value="60" size="lg" color="warning" />
blade
<zb:progress :value="60" size="lg" color="danger" />
blade
<zb:progress :value="60" size="lg" color="secondary" />
blade
<zb:progress :value="60" size="lg" color="dark" />
PropValues
sizesm | md | lg
colorprimary | secondary | success | danger | warning | info | dark

Striped and animated

Striped and animated: view
BLADE

striped adds diagonal stripes to the filled part, and animated moves them to show that the work is ongoing.

blade
<div class="space-y-4">
    <zb:progress :value="45" size="lg" striped />
    <zb:progress :value="80" size="lg" animated />
</div>
PropValues
stripedtrue | false
animatedtrue | false (turns on the stripes as well)

With Alpine

With Alpine: view
BLADE

alpine takes an Alpine expression; the bar follows its value without a page reload.

blade
<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>
PropValues
alpineAlpine expression (e.g. percent, file.progress)

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
value—null0 – 100; clamped and converted to an integer
alpine—nullAlpine expression; when given, it is used instead of value
label—nullScreen reader label; when empty, "Progress" (in the app language)
size—mdsm · md · lg
color—primaryprimary · secondary · success · danger · warning · info · dark; variant does the same
stripedbooleanfalseDiagonal stripes
animatedbooleanfalseMoving stripes (turns on striped as well)

Advanced

1 example

File upload progress

BLADE

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.

blade
<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

Events, hooks and details
  • A value given with alpine is not clamped; keeping it between 0 and 100 is up to you. The bar width and aria-valuenow follow the expression.
  • For users who prefer reduced motion, animated stripes stop moving.
Zubazar UI · ZubazarDesigned for people.