Skip to content
HomeCobalt

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

Guests and nights for a booking, held to the room's limits.

The Harbour suite sleeps 4.

CurrencyA minimum for gross assets in compact dollars, in steps of $100M.

Shift with an arrow key steps by $1B.

Another localeWith locale set to German the rate reads 145,00 €, and a comma in a typed figure is the decimal mark.

Charged in euros at check-in.

States

The weekend package is 3 nights.

DisabledNights are fixed by the package rate, so the field shows them and takes no input.
The Garden double sleeps 4. Book a second room.
InvalidMore guests than the room sleeps turns the field's fill to the error wash, with the reason under it.

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.json
import { NumberField, numberFieldLabels } from "@/components/cobalt/ui/number-field"