--- title: Number Field description: A numeric input element with increment and decrement buttons, and a scrub area. links: doc: https://base-ui.com/react/components/number-field#api-reference --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/number-field ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { NumberField, NumberFieldDecrement, NumberFieldGroup, NumberFieldIncrement, NumberFieldInput, NumberFieldScrubArea, } from "@/components/ui/number-field" ``` ```tsx ``` ## API Reference ### NumberField Root component. Styled wrapper for `NumberField.Root` from Base UI. | Prop | Type | Default | Description | | ------ | --------------------------- | ----------- | ------------------------------------------------ | | `size` | `"sm" \| "default" \| "lg"` | `"default"` | Controls the size of all child components via context | ### NumberFieldGroup Container for the input and buttons. Styled wrapper for `NumberField.Group` from Base UI. ### NumberFieldInput Input element for the number value. Styled wrapper for `NumberField.Input` from Base UI. ### NumberFieldIncrement Button to increment the value. Styled wrapper for `NumberField.Increment` from Base UI with plus icon. ### NumberFieldDecrement Button to decrement the value. Styled wrapper for `NumberField.Decrement` from Base UI with minus icon. ### NumberFieldScrubArea Draggable area for scrubbing the value. Styled wrapper for `NumberField.ScrubArea` from Base UI. | Prop | Type | Default | Description | | ------- | -------- | ------- | ------------------------------------------------ | | `label` | `string` | - | Label text displayed in the scrub area | ## Examples For accessible labelling and validation, prefer using the `Field` component to wrap number fields. See the related example: [Number field](/ui/docs/components/field#number-field). ### Small Size ### Large Size ### Disabled ### With External Label ### With Scrub ### With Range ### With Formatted Value ### With Step ### Form Integration