HextaUI

Progress: Animated value

Render <NumberFlow /> inside <ProgressValue /> so only the digits that change spin, in step with the fill.

Course completed
x
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import { NumberFlow } from "@/components/ui/number-flow"
import {
  Progress,
  ProgressLabel,
  ProgressValue,
} from "@/components/ui/progress"

export function ProgressNumberFlow() {
  const [value, setValue] = React.useState(42)

  return (
    <div className="flex w-full max-w-sm flex-col items-center gap-6">
      <Progress value={value}>
        <ProgressLabel>Course completed</ProgressLabel>
        <ProgressValue>
          {(_, current) => <NumberFlow value={current ?? 0} suffix="%" />}
        </ProgressValue>
      </Progress>
      <div className="flex gap-2">
        <Button
          variant="outline"
          size="sm"
          onClick={() => setValue(Math.max(0, value - 13))}
        >
          −13
        </Button>
        <Button
          variant="outline"
          size="sm"
          onClick={() => setValue(Math.min(100, value + 13))}
        >
          +13
        </Button>
      </div>
    </div>
  )
}

This adds the example as components/examples/progress/number-flow.tsx, together with the Progress component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/progress-number-flow.json

To add only the component, follow the Progress installation.

Props in this example

The Progress props this example sets, from the API reference.

PropTypeDefault
valuenull makes the bar indeterminate.
number | null–

Every prop is in the Progress API reference.

See them all, with keyboard support and accessibility notes, on the Progress page.