Number Field
Installation
Install the component via the CLI in one command.
npx shadcn@latest add @intentui/number-field
Composed components
When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.
Manual installation
Use this approach if you prefer to install and wire up the component yourself instead of using the CLI.
npm install react-aria-components @heroicons/react
Anatomy
import { NumberField, NumberInput } from "@/components/ui/number-field"
import { Label, Description, FieldError } from "@/components/ui/field"
<NumberField>
<Label/>
<NumberInput />
<Description />
<FieldError />
</NumberField>Examples
Controlled
You can use the number field as a controlled component by managing its state externally.
Uncontrolled
Like other fields, the search field can be controlled by managing its value through the defaultValue prop.
Validation
The field is in an error state, usually caused by invalid input. Try submitting the form without filling it out to see the error state in action.
Disabled
The field is disabled and cannot be interacted with.
Component API
NumberField
The NumberField component lets users enter numeric values.
| Prop | Type | Default |
|---|---|---|
className | string | - |
NumberInput
The NumberInput component renders the number field input.
| Prop | Type | Default |
|---|---|---|
className | string | - |
See the React Aria for the full API reference.
