HextaUI

Number flow: Only changed digits move

Each digit is its own column. Going from 22 to 23 spins only the ones digit; the tens digit stays still. Digits that appear or disappear, like the third digit in 99 → 100, slide their width in or out.

22
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import { NumberFlow } from "@/components/ui/number-flow"

const pairs = [
  [22, 23],
  [14, 19],
  [99, 100],
  [19, 21],
]

export function NumberFlowChangedDigits() {
  const [value, setValue] = React.useState(22)

  return (
    <div className="flex flex-col items-center gap-6">
      <NumberFlow value={value} className="text-5xl font-semibold" />
      <div className="flex flex-wrap justify-center gap-2">
        {pairs.map(([from, to]) => (
          <Button
            key={`${from}-${to}`}
            variant="outline"
            size="sm"
            onClick={() => setValue(value === from ? to : from)}
          >
            {from} ↔ {to}
          </Button>
        ))}
      </div>
    </div>
  )
}

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

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

To add only the component, follow the Number flow installation.

Props in this example

The Number flow props this example sets, from the API reference.

PropTypeDefault
valueRequired.
number–

Every prop is in the Number flow API reference.

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