Progress
newA progress bar with Nuxt UI's indeterminate animations, status, steps and seven sizes, and shadcn's label and value.
Open Props in the corner of the example to try color and size. color takes Button's colours or your own, primary by default. The bar, its track at 20% and the step names are drawn in the colour's text shade, which stays readable on the page where a bright success or warning wouldn't; all three follow the root's text colour, so class="text-foreground" still recolours them.
2xs to 2xl set the thickness from 1 to 20px, and the size of the status and step text. md is the default.
Installation
Usage
<script setup lang="ts">
import { Progress } from '@/components/ui/progress'
const value = ref(40)
</script>
<template>
<Progress v-model="value" />
</template>
The API is Nuxt UI's Progress, without ui: the parts are styled through their data-slot.
Examples
Indeterminate
Without a value, or with null, the bar is indeterminate and animated. animation picks the movement: carousel (the default), carousel-inverse, swing or elastic. The carousels run the other way in right-to-left, as the fill grows from the right, and every animation becomes a slow pulse under reduced motion. The bar takes the direction from Reka's ConfigProvider and renders it as its own dir; <html dir="rtl"> alone is not read, so a right-to-left app wraps itself in ConfigProvider dir="rtl".
Status
status shows the percentage above the bar, where the fill ends. Replace it through the status slot, which receives percent.
Steps
An array as max gives the bar one step per item: the value is the index of the current step, and its name shows under the bar. Replace a step's name through its step-<index> slot, which receives step.
Orientation
orientation="vertical" fills the height of the container from the top; inverted fills either orientation from the other end.
Label and value
ProgressLabel and ProgressValue go in the default slot and sit in a row above the bar. The label names the bar for screen readers. The value shows the percentage and is hidden from screen readers, since the bar already reports its value; its slot receives percent, value and max.
API Reference
Progress
class is also accepted on every part and merged over its classes with tailwind-merge.
| Prop | Default | Type and description |
|---|---|---|
| as | "div" | AsTag | ComponentThe element or component to render. |
| max | undefined | number | unknown[]The value that fills the bar, 100 by default. An array names one step per value, from |
| status | — | booleanShows the percentage above the bar, moving with the value. |
| inverted | false | booleanFills the bar from the other end, right to left or bottom to top. |
| color | "primary" | ProgressColor | (string & {})Colour role of the bar, its track at 20% and the step names, all in the colour's text shade so they stay readable on the page. Any other name picks up a colour you declare on |
| size | "md" | ProgressSizeThickness of the bar, from 1px for |
| orientation | "horizontal" | ProgressOrientation
|
| animation | "carousel" | ProgressAnimationHow an indeterminate bar moves. Under reduced motion every animation becomes a slow pulse. |
| getValueLabel | — | ((value: number | null | undefined, max: number) => string | undefined)Returns the bar's |
| getValueText | — | ((value: number | null | undefined, max: number) => string | undefined)Returns the bar's |
| modelValue | null | number | nullThe value, bound with |
| Event | Payload and description |
|---|---|
| update:modelValue | [value: string[] | undefined]Not fired for an out-of-range value, which the bar clamps to |
| update:max | [value: number]Fires when Reka corrects an invalid |
| Slot | Scope and description |
|---|---|
| default | anyA header row above the bar for |
| status | { percent?: number | undefined; }Replaces the percentage shown by |
ProgressValue
| Slot | Scope and description |
|---|---|
| default | { percent: number | undefined; value: number | null | undefined; max: number; }Replaces the percentage. Receives |
ProgressLabel
| Slot | Scope and description |
|---|---|
| default | {}The label. It names the progress bar for screen readers. |
class is also accepted on every part and merged over its classes with tailwind-merge.
Props
- as
"div" AsTag | ComponentThe element or component to render.- max
undefined number | unknown[]The value that fills the bar, 100 by default. An array names one step per value, from0to its length less one, and shows the current step's name under the bar.- status
booleanShows the percentage above the bar, moving with the value.- inverted
false booleanFills the bar from the other end, right to left or bottom to top.- color
"primary" ProgressColor | (string & {})Colour role of the bar, its track at 20% and the step names, all in the colour's text shade so they stay readable on the page. Any other name picks up a colour you declare on[data-slot][data-color="<name>"].- size
"md" ProgressSizeThickness of the bar, from 1px for2xsto 20px for2xl, and the size of the status and step text.- orientation
"horizontal" ProgressOrientationverticalfills the height of its container instead of the width.- animation
"carousel" ProgressAnimationHow an indeterminate bar moves. Under reduced motion every animation becomes a slow pulse.- getValueLabel
((value: number | null | undefined, max: number) => string | undefined)Returns the bar'saria-labelfrom the value and max; a percentage by default. AProgressLabeltakes precedence.- getValueText
((value: number | null | undefined, max: number) => string | undefined)Returns the bar'saria-valuetextfrom the value and max.- modelValue
null number | nullThe value, bound withv-model.nullmakes the bar indeterminate and animated.
Emits
- update:modelValue
[value: string[] | undefined]Not fired for an out-of-range value, which the bar clamps to0tomaxwhile your model keeps it;NaNshows an indeterminate bar.- update:max
[value: number]Fires when Reka corrects an invalidmaxto 100.
Slots
- default
anyA header row above the bar forProgressLabelandProgressValue.- status
{ percent?: number | undefined; }Replaces the percentage shown bystatus. Receivespercent.
Slots
- default
{ percent: number | undefined; value: number | null | undefined; max: number; }Replaces the percentage. Receivespercent,valueandmax.
Slots
- default
{}The label. It names the progress bar for screen readers.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| progress | data-color, data-orientation, data-size | The root. |
| progress-header | — | The row around the default slot, rendered only when it is used. |
| progress-status | — | The percentage shown by status. |
| progress-track | data-state, data-value, data-max | The track, with role="progressbar". data-state is indeterminate, loading or complete. |
| progress-indicator | data-state | The fill. |
| progress-steps | — | The step names under the bar. |
| progress-step | data-state | One step name. data-state is active or first for the current step, other for the rest. |
| progress-label | — | The label. |
| progress-value | — | The percentage beside the label. |