Installation
Add Component
Copy the code snippet below into you components folder.
Integrate Recipe
Integrate this recipe in to your Panda config.
Usage
If you prefer a closed component composition, check out the snippet below.
Shortcuts
The NumberInput component provides a set of shortcuts for common use cases
NumberInput.Control
This component renders the NumberInput.IncrementTrigger and NumberInput.DecrementTrigger within it by default.
Writing this:
is shorthand for writing this if you don't need to customize the triggers:
Examples
Sizes
Pass the size prop to change the size of the number input.
Formatting
Pass the formatOptions prop to format the number input value. The value of this maps to Intl.NumberFormatOptions and is applied based on the current locale.
Min and Max
Pass the min and max props  to set the minimum and maximum values of the number input.
If value entered is less than min or greater than max, the value will be clamped to the nearest boundary on blur, or enter key press.
Step
Pass the step prop  to change the increment or decrement interval of the number input.
Controlled
Pass the value and onValueChange props to control the value of the number input.
Mouse Wheel
Pass the allowMouseWheel prop to enable or disable the mouse wheel to change the value of the number input.
Disabled
Pass the disabled prop  to disable the number input.
Invalid
Use the Field component and the invalid prop to indicate that the number input is invalid.
Helper Text
Compose the Field and Field.HelperText components to add helper text to the number input.
Element
Here's an example of how to compose the number input with the input group component to add an element on either the left or right.
Scrubber
Use the NumberInput.Scrubber component to make the number input supports scrubber interactions.
Closed Component
Here is an example of how to use the NumberInput component in a closed manner.
and use it like this:
Props
Root
| Prop | Default | Type | 
|---|---|---|
| size | 'md' | 'sm' | 'md' | 'lg' | 'xl' | 
| variant | 'outline' | 'outline' | 
| allowOverflow | true | booleanWhether to allow the value overflow the min/max range | 
| clampValueOnBlur | true | booleanWhether to clamp the value when the input loses focus (blur) | 
| focusInputOnChange | true | booleanWhether to focus input when the value changes | 
| inputMode | \decimal\ | InputModeHints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices | 
| locale | \en-US\ | stringThe current locale. Based on the BCP 47 definition. | 
| max | Number.MAX_SAFE_INTEGER | numberThe maximum value of the number input | 
| min | Number.MIN_SAFE_INTEGER | numberThe minimum value of the number input | 
| pattern | \-?[0-9]*(.[0-9]+)?\ | stringThe pattern used to check the <input> element's value against | 
| spinOnPress | true | booleanWhether to spin the value when the increment/decrement button is pressed | 
| step | 1 | numberThe amount to increment or decrement the value by | 
| allowMouseWheel | booleanWhether to allow mouse wheel to change the value | |
| asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. | |
| defaultValue | stringThe initial value of the input when rendered. Use when you don't need to control the value of the input. | |
| disabled | booleanWhether the number input is disabled. | |
| form | stringThe associate form of the input element. | |
| formatOptions | NumberFormatOptionsThe options to pass to the `Intl.NumberFormat` constructor | |
| id | stringThe unique identifier of the machine. | |
| ids | Partial<{
  root: string
  label: string
  input: string
  incrementTrigger: string
  decrementTrigger: string
  scrubber: string
}>The ids of the elements in the number input. Useful for composition. | |
| invalid | booleanWhether the number input value is invalid. | |
| name | stringThe name attribute of the number input. Useful for form submission. | |
| onFocusChange | (details: FocusChangeDetails) => voidFunction invoked when the number input is focused | |
| onValueChange | (details: ValueChangeDetails) => voidFunction invoked when the value changes | |
| onValueInvalid | (details: ValueInvalidDetails) => voidFunction invoked when the value overflows or underflows the min/max range | |
| readOnly | booleanWhether the number input is readonly | |
| required | booleanWhether the number input is required | |
| translations | IntlTranslationsSpecifies the localized strings that identifies the accessibility elements and their states | |
| value | stringThe controlled value of the input |