Number Field
Numeric input with keyboard entry, step controls, range constraints, formatting and optional scrubbing.
Purpose
Use Number Field for numeric values that benefit from keyboard entry, step buttons, optional scrubbing and explicit range or formatting rules.
Stepped number
Installation
With the Siteplane registry alias configured, add the component and import the installed source from your app.
CLI
pnpm dlx shadcn@4.16.1 add @siteplane/number-fieldImport
import { NumberField } from "@/components/ui/number-field";
import { CursorGrowIcon, NumberFieldDecrement, NumberFieldGroup, NumberFieldIncrement, NumberFieldInput, NumberFieldScrubArea } from "@/components/ui/number-field";
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";
import { Form } from "@/components/ui/form";
import { Label } from "@/components/ui/label";Need the machine-readable source metadata? View registry JSON.
Usage
Use Number Field for numeric input with increment, decrement and optional scrub controls.
import { NumberField, NumberFieldDecrement, NumberFieldGroup, NumberFieldIncrement, NumberFieldInput } from "@/components/ui/number-field";
export function Example() {
return (
<NumberField defaultValue={12} min={0}>
<NumberFieldGroup>
<NumberFieldDecrement />
<NumberFieldInput aria-label="Seats" />
<NumberFieldIncrement />
</NumberFieldGroup>
</NumberField>
);
}Examples
Sizes, states, range and step limits, formatted values and form integration are props and compositions of the same primitive.
Sizes
States
Min, max and step
Formatted value
Form integration
External label
The root id is forwarded to the input, so an external Label can target it with htmlFor.
Rolling digits
Optional variant: only the digits that change roll vertically on increment and decrement.
API Reference
The reference lists the source-owned exports and props that are easy to miss in visual examples. Inherited Base UI props remain available unless the wrapper narrows them.
NumberFieldowns the value and accepts the Base UI number-field props plussize="sm" | "default" | "lg" | "xl".size="xl"gives the composed group the shared 56px customer-facing outer height and 16px value text. Use the surrounding provider'sradius="sm"personality for the global 8px main corner.- Compose
NumberFieldGroup,NumberFieldInput,NumberFieldDecrementandNumberFieldIncrementfor the standard control. NumberFieldScrubAreaadds a labelled drag target for changing the value;CursorGrowIconis the matching visual indicator.- Configure
min,max,step,format, controlledvalueor uncontrolleddefaultValueonNumberField, not on the input slot.
Motion
Component motion uses the shared Siteplane motion contract. See the global motion guide for provider setup, tokens and reduced-motion behavior.
- Number Field adds no root-level enter or exit animation. Button feedback, focus, disabled and invalid states come from the native Siteplane primitives.
- Scrubbing updates the value directly without moving the surrounding layout. The optional Rolling Digits documentation example is not part of the default primitive and reduces its digit transition to one frame in system and provider reduced-motion modes.
Accessibility
- Provide a visible label through
FieldLabelor an explicit accessible name. - Give
NumberFieldScrubAreaa label that describes the value it changes. - Keep increment, decrement and keyboard behavior on the Base UI-backed slots, and pair invalid state with a visible
FieldError.
Implementation Guidance
- Use Input for free-form text and Slider for visual range selection.
- Do not rebuild a numeric input from raw browser controls when Number Field fits.
- Keep range, step and formatting rules on the root so every input method shares one contract.