Number field
Takes a count or an amount that a person nudges more often than types, such as guests, nights or a size threshold, with a minus and a plus beside the figure.
Examples
The Harbour suite sleeps 4.
Shift with an arrow key steps by $1B.
Charged in euros at check-in.
States
The weekend package is 3 nights.
The Garden double sleeps 4. Book a second room.
Usage
Use it when
- A small count a person changes by one or two: guests, rooms, nights, seats.
- A threshold with a natural step: gross assets of at least $1B in steps of $100M.
Use something else when
- A figure with no natural step, such as a price typed from an invoice. Use Input instead, with
inputMode="decimal". - A choice of up to 6 fixed values, such as 1, 2 or 3 bedrooms. Use SegmentedControl instead.
- A range with two ends, such as 2 to 8 nights. Use two NumberFields in one Field row instead, or Select for set bands.
Rules
General
Avoid
Limits
Install
npx shadcn@latest add https://kaanarici.com/r/cobalt/number-field.jsonimport { NumberField, numberFieldLabels } from "@/components/cobalt/ui/number-field"