Skip to content

InputNumber ​

Introduction ​

The InputNumber component is a versatile numeric input with increment/decrement buttons, supporting various layouts, sizes, validation states, and full reactivity via Pulse signals. It is ideal for quantity selectors, forms, booking flows, and any scenario requiring controlled numeric input.

Import ​

tsx
import { InputNumber } from '@odyssee/components';

LiveCodeEditor Examples ​

Basic InputNumber ​

Code Éditable
Résultat

Reactive Value ​

Code Éditable
Résultat

Variants ​

Code Éditable
Résultat

Sizes ​

Code Éditable
Résultat

Min, Max & Step ​

Code Éditable
Résultat

States: Error, Disabled, Readonly, Required, Hint ​

Code Éditable
Résultat

Props Table ​

PropTypeDefaultDescription
valuenumber | Signal<number>—Numeric value (can be reactive signal).
minnumber—Minimum allowed value.
maxnumber—Maximum allowed value.
stepnumber1Increment/decrement step.
variant"default" | "vertical" | "horizontal" | "mini""default"Layout variant for the component.
labelstring—Label displayed above the input.
descriptionstring—Optional description below the label.
errorstring—Error message displayed below the input.
hintstring—Optional hint text below the input.
size"xs" | "sm" | "md" | "lg" | "xl""md"Size of the input and buttons.
disabledbooleanfalseDisables the input and buttons.
readonlybooleanfalseMakes the input read-only.
requiredbooleanfalseMarks the input as required.
onChange(value: number) => void—Callback fired when the value changes.
classNamestring—Additional CSS classes for the root element.
namestring—Name attribute for form integration.
idstringauto-genUnique ID for the input number element.
...restany—Other props are spread to the root element.

Implementation Notes ​

  • Fully reactive: supports Pulse signals for value and state.
  • Increment/decrement buttons are disabled at min/max boundaries.
  • Supports multiple layout variants: default, vertical, horizontal, mini.
  • Validation states (error, required, disabled, readonly) affect styling and accessibility.
  • Step can be fractional for decimal inputs.
  • Label, description, hint, and error are styled for clarity and accessibility.
  • Size prop adjusts input and button dimensions.

Accessibility ​

  • Uses native <input type="number"> for full accessibility.
  • Buttons are keyboard-accessible and include ARIA labels.
  • Error and hint messages are announced via text.
  • Disabled and readonly states are visually and programmatically indicated.
  • Label is linked via for and id attributes.

Best Practices ​

  • Use min, max, and step to constrain input and guide user interaction.
  • Prefer signals for reactive value management in forms.
  • Use variants to match UI context (vertical for forms, mini for compact controls).
  • Provide clear labels and descriptions for context.
  • Use validation states to guide user input and improve UX.
  • Avoid disabling unless necessary; provide visual cues if disabled.

Released under the MIT License.