vael-ui v0.5.7

Feedback

Layout

Progress

A bar or ring for a task’s progress, known or unknown, or for stacked shares of a whole with a legend. Use it for uploads, long tasks or a storage breakdown.

Install

import { Progress } from 'vael-ui'

Playground

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { Progress } from 'vael-ui'
</script>

<template>
  <Progress :value="60" aria-label="Upload progress" />
</template>

Props

NameTypeDefaultDescription
valuenumber | ProgressSegment[] | nullOne value, or segments that stack into one bar (a storage breakdown, a budget): each is { value, label?, variant?, color?, tooltip?, class?, style? }. null/undefined renders the indeterminate (looping) state.
maxnumber100Value that counts as complete; Progress clamps value to 0–max.
labelstringAccessible label for the progress bar.
valueTextstringHuman-readable reading for assistive tech (aria-valuetext), e.g. "42 GB of 100 GB".
variant'primary' | 'danger' | 'success' | 'warning' | 'info''primary'Fill color variant for one value, and the base color segments shade from.
type'circle' | 'line''line''circle' draws a ring; the default slot sits in its middle. Segments work in both.
sweepnumber360How much of the circle a ring covers, in degrees, with the gap centred at the bottom: 180 is a half-ring gauge, 270 a speedometer. The value always fills that whole arc.
size'sm' | 'md''md'Track thickness, or the ring's size and thickness.
legendbooleantrueRenders a legend under stacked segments that have labels.
motionProgressMotiontrueHow it moves: its appearance ({ initial: { track: { opacity: 0 } } }) and its states ({ states: { complete: { root: { scale: [1, 1.02, 1] } } } }). { when: 'visible' } fills it once it scrolls into view. false skips the fill transition; drive fillEl/fillEls yourself.
uiPartial<Record<'root' | 'track' | 'fill' | 'legend' | 'legendItem', UiPartValue>>Class and style overrides for each part.

Events

No events.

Slots

NameTypeDescription
default{ percent: number; value: number; }Content in the middle of a ring, or inside the arch of a gauge, such as the percentage.
legend{ segment: ProgressSegment; index: number; percent: number; }Replaces one legend row.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element.
fillElHTMLElement | SVGPathElement | nullThe first fill: a bar's <div> or a ring's <path>. Its share comes from the --ui-progress-scale custom property, and a ring segment's start from --ui-progress-start.
fillEls(HTMLElement | SVGPathElement)[]Every fill, one per stacked segment, in order.
partsRecord<string, HTMLElement | HTMLElement[] | null>Its elements by part name, for your own animation; a repeated part is an array.

Motion New

Progress: its appearance, states, and the fill's timing and when: 'visible'.

<Progress
  :motion="{ states: { complete: { root: { scale: 1.04 } } } }"
/>
NameTypeDescription
initialexitroottrackfilllegendSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
statescompleteindeterminateSets values per part that hold while a state is on. An array is a set of keyframes that plays once as the state turns on, such as a shake on invalid.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
spring{ damping, response }Times how its value moves when it changes, from the steppers, the keyboard or your code.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

It has no keyboard interaction of its own.

  • Renders role="progressbar" with aria-valuemin="0", aria-valuemax and aria-valuenow. With no value, it is indeterminate and leaves out aria-valuenow.
  • Name it with the label prop, aria-label or aria-labelledby. They land on the bar, not the wrapper, and so does aria-describedby.
  • With segments, aria-valuenow is their total. valueText sets aria-valuetext, such as “42 GB of 100 GB”.
  • Under reduced motion, the fill stops transitioning and the indeterminate state pulses instead of sliding.