Counter
A plus/minus number picker whose digits roll into place, plus the SlidingNumber behind it.
Preview
Usage
import { Counter } from '@vitnode/core/components/ui/counter'const [quantity, setQuantity] = React.useState(1)
<Counter aria-label="Tickets" max={10} min={1} onValueChange={setQuantity} value={quantity} />Digits roll the short way round: 9 → 10 rolls to 0 as a new 1 slides in. For
uncontrolled use, pass defaultValue.
Steps and limits
A step that would pass a limit stops at it: with max={12} and step={5},
10 goes to 12. Buttons disable at min and max.
Sliding number
The rolling digits on their own, for any number.
import { SlidingNumber } from '@vitnode/core/components/ui/sliding-number'<SlidingNumber className="text-5xl font-semibold" value={downloads} />It inherits font size and color, uses tabular figures, and handles negatives and up to 6 decimals.
In a form
Counter is a standalone control. To save a number with AutoForm, use Number Field.
Accessibility
- The buttons are labelled "Decrease" / "Increase" in the user's language.
- Screen readers hear each new value, not the rolling digits.
- Name the counter with
aria-labeloraria-labelledby. "Increase" what? - With reduced motion, digits change instantly.
Props
Counter
Prop
Type
SlidingNumber
Prop
Type