Number Input
Shared label and supporting-text behaviour with catnip-input is summarised on Inputs overview.
catnip-input-number
Props
Value & constraints
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| modelValue | number | null | null | — | Numeric value; model-value in HTML / .modelValue in frameworks. |
| min | number | — | — | Minimum value. The steppers and arrow keys stop at it; a typed value below it isn't committed and is flagged on blur. |
| max | number | — | — | Maximum value. The steppers and arrow keys stop at it; a typed value above it isn't committed and is flagged on blur. |
| step | number | 1 | — | Increment/decrement amount for steppers and arrow keys. Also sets display precision: 0.1 → 1 decimal, 0.01 → 2, 1 → integers. |
| placeholder | string | "" | — | Shown when modelValue is null. |
Digit grouping & decimals
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| separateAt | number | — | — | Group the integer part every N digits from the right. Omit or 0 = off. |
| separator | string | "," | ,, ., (space) | Thousands separator when separateAt > 0. Must differ from decimalSeparator. |
| decimalSeparator | string | "." | ,, . | Character between integer and fractional parts (e.g. 1,5 vs 1.5). |
Field presentation
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| label | string | "" | — | Visible field label when the label slot is empty. |
| optional | boolean | false | — | When true and not required, shows the localized optional hint. |
| optionalText | string | "" | — | Overrides the localized optional hint (HTML: optional-text). |
| info | string | "" | — | Info tooltip beside the label; when non-empty, it wins over the label.suffix slot. |
| alignment | "left" | "center" | "right" | "left" | left, center, right | Horizontal alignment of the field label block. |
| requiredMarker | string | "*" | — | Visual marker for required fields (HTML: required-marker). |
| requiredScreenReaderText | string | "" | — | Optional screen-reader supplement; it does not replace required on the control (HTML: required-screen-reader-text). |
| supportingText | SupportingTextProp | "" | — | One or more helper or validation messages. Each object requires text; intent accepts neutral, danger, warning, or success, and icon accepts a Catnip icon name. See supporting-text examples. |
State
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| size | "s" | "m" | "l" | "m" | s, m, l | Control heights 32px, 40px, and 48px with corresponding typography. |
| intent | "neutral" | "danger" | "warning" | "success" | "neutral" | neutral, danger, warning, success | Semantic state applied to field and supporting-text styling; danger sets aria-invalid on the input. |
| disabled | boolean | false | — | Disables the control and steppers. |
| readonly | boolean | false | — | Read-only control and steppers. |
| required | boolean | false | — | Native required and label marker. |
| inputNumberAriaLabel | string | "" | — | aria-label when there is no visible label. |
| ariaDescribedby | string | "" | — | IDs of elements in the page, or in the shadow root the element sits in, that describe the field. They're resolved there and connected to the inner control by element reflection, read before the supporting text. |
Advanced
| Prop | Type | Default | Options | Description |
|---|---|---|---|---|
| inputNumberId | string | "" | — | DOM id for the input. Auto-generated when omitted. |
| name | string | "" | — | Native name for form submission. |
| inputNumberAutofocus | boolean | false | — | Forwards native autofocus to the input; use sparingly. |
| autocomplete | string | "" | — | Input purpose for autofill (WCAG 1.3.5), for example postal-code. Empty leaves it unset. |
| hideLabel | boolean | false | — | Visually hides the label row; label still names the spinbutton. |
| testSelectors | TestSelectorsProp | See Test Selectors | — | Overrides stable data-test values. |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | number | null | Value changed (unformatted number): a valid number in range while typing, null when cleared, or a step. Text that isn't a valid number in range isn't emitted. |
Slots
Label row
| Name | Description |
|---|---|
| label | Custom label content; falls back to label prop. |
| label.action | Trailing action in the label row (e.g. link). |
| label.suffix | Custom label suffix (suffix slot); used only when info is empty. |
Test selectors
| Attribute | Default | Applies to |
|---|---|---|
root | catnip-input-number | Field wrapper |
control | catnip-input-number-control | The native text input |
decrementButton | catnip-input-number-decrement | Decrease (−) button |
incrementButton | catnip-input-number-increment | Increase (+) button |
supportingText | catnip-input-supporting-text | Supporting message |