();
return (
<>
Quantity
Quantity: {value()}. Raw: {rawValue()}.
>
);
}
```
```
Copytsx
import { createSignal } from "solid-js";
function ControlledExample() {
const [value, setValue] = createSignal("40");
const [rawValue, setRawValue] = createSignal();
return (
<>
Quantity
Quantity: {value()}. Raw: {rawValue()}.
>
);
}
```
### Description
The `NumberField.Description` component can be used to associate additional help text with a number field.
Quantity
ArrowArrow
Choose a quantity.
```
Copytsx
Quantity
Choose a quantity.
```
```
Copytsx
Quantity
Choose a quantity.
```
### Error message
The `NumberField.ErrorMessage` component can be used to help the user fix a validation error. It should be combined with the `validationState` prop to semantically mark the text field as invalid for assistive technologies.
By default, it will render only when the `validationState` prop is set to `invalid`, use the `forceMount` prop to always render the error message (ex: for usage with animation libraries).
Quantity
ArrowArrow
Hmm, I prefer 40.
```
Copytsx
import { createSignal } from "solid-js";
function ErrorMessageExample() {
const [rawValue, setRawValue] = createSignal();
return (
Quantity
Hmm, I prefer 40.
);
}
```
```
Copytsx
import { createSignal } from "solid-js";
function ErrorMessageExample() {
const [rawValue, setRawValue] = createSignal();
return (
Quantity
Hmm, I prefer 40.
);
}
```
### HTML forms
The number field `name` prop along with `` can be used for integration with HTML forms. Only the raw value is passed to the form.
If the formatted value is wanted (unrecommended) set the `name` attribute on ``.
Quantity
ArrowArrow
ResetSubmit
```
Copytsx
function HTMLFormExample() {
const onSubmit = (e: SubmitEvent) => {
// handle form submission.
};
return (
);
}
```
```
Copytsx
function HTMLFormExample() {
const onSubmit = (e: SubmitEvent) => {
// handle form submission.
};
return (
);
}
```
### Triggers
The number field supports optional increment/decrement triggers that are easily customizable.
Quantity
-+
```
Copytsx
Quantity
-
+
```
```
Copytsx
Quantity
-
+
```
### Format
The value of the number field component can be formatted based on the [locale with the `I18NProvider`](https://kobalte.dev/docs/core/components/i18n-provider) and `formatOptions`. For more information see [React Spectrum NumberField](https://react-spectrum.adobe.com/react-spectrum/NumberField.html).
Price
ArrowArrow
```
Copytsx
Price
```
```
Copytsx
Price
```
### Autofill
The number field supports autofill through `NumberField.HiddenInput`.
```
Copytsx
Quantity
```
```
Copytsx
Quantity
```
## API Reference
### NumberField
`NumberField` is equivalent to the `Root` import from `@kobalte/core/number-field` (and deprecated `NumberField.Root`).
| Prop | Description |
| --- | --- |
| value | `string | number`
The controlled formatted value of the number field. |
| defaultValue | `string | number`
The default value when initially rendered. Useful when you do not need to control the value. |
| onChange | `(value: string) => void`
Event handler called when the value of the NumberField changes as a formatted value. |
| rawValue | `number`
The controlled raw value of the number field. |
| onRawValueChange | `(value: number) => void`
Event handler called when the value of the NumberField changes as a number. |
| minValue | `number`
The smallest value allowed in the number field, defaults to `Number.MIN_SAFE_INTEGER`. |
| maxValue | `number`
The largest value allowed in the number field, defaults to `Number.MAX_SAFE_INTEGER`. |
| step | `number`
Increment/Decrement step when using the triggers or the arrows on keyboard in the number field. |
| largeStep | `number`
Increment/Decrement step when using the Page UP/Down keys in the number field, defaults `10 * step`. |
| changeOnWheel | `boolean`
Whether to increment/decrement on wheel scroll inside the number field. |
| format | `boolean`
Whether to format the input value. |
| formatOptions | [`Intl.NumberFormatOptions`](https://github.com/microsoft/TypeScript/blob/353ccb7688351ae33ccf6e0acb913aa30621eaf4/src/lib/es2020.intl.d.ts#L243-L251)
Formating options for the value of the number field. |
| allowedInput | `RegExp`
Allowed input characters in the number field (only prevents onInput, not paste), defaults to locale and format characters. |
| name | `string`
The name of the NumberField.HiddenInput of the number field, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname). |
| validationState | `'valid' | 'invalid'`
Whether the number field should display its "valid" or "invalid" visual styling. |
| required | `boolean`
Whether the user must fill the number field before the owning form can be submitted. |
| disabled | `boolean`
Whether the number field is disabled. |
| readOnly | `boolean`
Whether the number field items can be selected but not changed by the user. |
| Data attribute | Description |
| --- | --- |
| data-valid | Present when the number field is valid according to the validation rules. |
| data-invalid | Present when the number field is invalid according to the validation rules. |
| data-required | Present when the user must fill the number field before the owning form can be submitted. |
| data-disabled | Present when the number field is disabled. |
| data-readonly | Present when the number field is read only. |
`NumberField.Label`, `NumberField.Input`, `NumberField.HiddenInput`, `NumberField.Description` and `NumberField.ErrorMesssage` share the same data-attributes.
### NumberField.ErrorMessage
| Prop | Description |
| --- | --- |
| forceMount | `boolean`
Used to force mounting when more control is needed. Useful when controlling animation with SolidJS animation libraries. |
## Rendered elements
| Component | Default rendered element |
| --- | --- |
| `NumberField` | `div` |
| `NumberField.Label` | `label` |
| `NumberField.Input` | `input` |
| `NumberField.HiddenInput` | `input` |
| `NumberField.IncrementTrigger` | `button` |
| `NumberField.DecrementTrigger` | `button` |
| `NumberField.Description` | `div` |
| `NumberField.ErrorMessage` | `div` |
Previous[←Navigation Menu](https://kobalte.dev/docs/core/components/navigation-menu)Next[Pagination→](https://kobalte.dev/docs/core/components/pagination)