Progress

A bar that fills to show how far a task has progressed.

Usage

Code
import { Progress } from '@leverui/components';
Code
<Progress.Root>
  <Progress.Track>
    <Progress.Range />
  </Progress.Track>
  <Progress.Label />
  <Progress.ValueText />
</Progress.Root>

Examples

Sizes

Use the size prop to change the size of the progress bar.

Variants

Use the variant prop to change the visual style of the progress bar.

Colors

Use the colorPalette prop to change the color of the progress bar.

gray

red

green

blue

teal

pink

purple

cyan

orange

yellow

Inline Label

Compose the Progress.Label and Progress.ValueText components to create an inline label for the progress bar.

Usage
40%

Info tip

Use a Popover inside Progress.Label to add a tooltip to the progress bar.

Uploading

Indeterminate

Set the value to null to show an indeterminate progress bar.

Stripes

Set the striped prop to true to add stripes to the progress bar.

Animated Stripes

Set the animated prop to true to animate the stripes.

Closed Component

Wraps the parts in one component that takes props. Uses InfoTip.

Code
import { Show, omit } from 'solid-js';
import type { JSX } from '@solidjs/web';
import { InfoTip, Progress, type ProgressRootProps } from '@leverui/components';

export type ClosedProgressProps = ProgressRootProps & {
  showValueText?: boolean | undefined;
  valueText?: JSX.Element;
  label?: JSX.Element;
  info?: JSX.Element;
};

export function ClosedProgress(props: ClosedProgressProps) {
  const root = omit(props, 'showValueText', 'valueText', 'label', 'info');

  return (
    <Progress.Root {...root}>
      <Show when={props.label}>
        <Progress.Label>
          {props.label}{' '}
          <Show when={props.info}>
            <InfoTip>{props.info}</InfoTip>
          </Show>
        </Progress.Label>
      </Show>
      <Progress.Track>
        <Progress.Range />
      </Progress.Track>
      <Show when={props.showValueText}>
        <Progress.ValueText>{props.valueText}</Progress.ValueText>
      </Show>
    </Progress.Root>
  );
}

Guides

Values and composition

Pass value to control the progress, or defaultValue to let the component track it. min and max set the range. value={null} is the indeterminate state: the track has no aria-valuenow. Set orientation="vertical" for a vertical bar.

useProgress creates the state outside the component, to pass to Progress.RootProvider. useProgressContext and Progress.Context read the nearest one. ProgressPropsProvider sets reactive default props for the roots inside it. A prop on a root wins.

Accessibility

Track gets role="progressbar" and the value attributes. Progress.Label is not linked automatically: give it an ID and point aria-labelledby on Track at it. For a label rendered elsewhere, point aria-labelledby at that text, or set aria-label on Track.

ValueText is a polite live region, so screen readers announce each change. For a fast task, update the text at a pace that is useful to hear.

Props

Root

PropDefaultTypeDescription
defaultValue50numberStarting value, when you do not control it.
formatOptions{ style: 'percent' }NumberFormatOptionsOptions for formatting the value.
locale'en-US'stringLocale for formatting the value.
max100numberLargest value.
orientation'horizontal''horizontal' | 'vertical'Bar direction.
colorPalette'gray''gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'Color palette.
variant'outline''outline' | 'subtle'Bar style.
shape'rounded''square' | 'rounded' | 'full'Bar shape.
size'md''xs' | 'sm' | 'md' | 'lg' | 'xl'Bar size.
as—'div'HTML tag to render.
asChild—Solid render functionRender your own element with the root's props.
unstyled—booleanTurn off the Lever UI styles.
id—stringUnique id for the progress bar.
ids—Partial<{ root: string; track: string; label: string; circle: string }>Ids for the elements in the progress bar.
min0numberSmallest value.
onValueChange—(details: ValueChangeDetails) => voidCalled when the value changes.
translations—IntlTranslationsTranslated messages.
value—number | nullValue, when you control it.
striped—booleanAdd stripes.
animated—booleanAnimate the stripes.

Customize with CSS

Import @leverui/components/styles.css before your own stylesheet. Set the public --leverui-* variables or style the stable .leverui-progress__* classes, such as .leverui-progress__range.

Track variables: --leverui-progress-track-height, --leverui-progress-track-color, and --leverui-progress-track-radius. Range variable: --leverui-progress-range-color.

unstyled turns off the default styles but keeps the semantics and the styling hooks. class and style work on any part.

Explorer

Click a part name in the sidebar to highlight it in the preview.

Component Anatomy

Hover to highlight, click to select parts