Skip to content
GitHub (opens in a new tab)

NumberInput

A number the person can type, step, and read in their locale, with optional min and max.

stableMoleculecontracts/numberinput.json

Preview

NumberInput

A number with locale formatting, min, max, and step. Arrow keys and the stepper buttons move by step. Money is CurrencyInput.

Master

Grouping appears when the field is not focused. Typing uses the locale decimal mark.

Usage

Wrap with Field. Blur clamps to min and max. Use Slider for a rough amount on a track, and CurrencyInput for money.

Do's

  • A quantity, percentage, or other number in a form
  • The value should format with the locale's grouping and decimal mark
  • Arrow keys or stepper buttons should move by a step

Don'ts

<Field label="Quantity" htmlFor="qty"><NumberInput id="qty" min={1} max={99} step={1} /></Field>

When to use

  • A quantity, percentage, or other number in a form
  • The value should format with the locale's grouping and decimal mark
  • Arrow keys or stepper buttons should move by a step

When not to use

  • Money — use CurrencyInput
  • A rough amount on a track — use Slider
  • Free text — use Input

What an agent reads

import { NumberInput } from "agentic-ds-kit";
must
  • Input is role=spinbutton with aria-valuenow, aria-valuemin, aria-valuemax, and aria-valuetext
  • ArrowUp and ArrowDown move by step and clamp to min and max
  • Blur clamps a typed value to min and max
  • Stepper buttons are labelled Decrease value and Increase value
  • Must have a Field label or ariaLabel
  • built-in labels (decreaseValue, increaseValue) come from KitLabelsProvider; English by default
defaults
  • size md
  • step 1
  • disabled false
  • error false
  • steppers true
stops if
  • Do not use input type=number when the locale format matters
  • Do not put a currency symbol on NumberInput — use CurrencyInput
  • Do not use raw hex

From contracts/numberinput.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
idstringYes——
sizemd | sm | lgNomd—
valuenumber | nullNo—Controlled. null is empty.
defaultValuenumber | nullNo——
onChangefunctionNo—(value: number | null) => void
minnumberNo——
maxnumberNo——
stepnumberNo1—
localestringNo—BCP 47. Default is the runtime locale.
placeholderstringNo——
disabledbooleanNofalse—
errorbooleanNofalse—
namestringNo——
describedBystringNo——
ariaLabelstringNo——
steppersbooleanNotrueDecrease and increase buttons.
  • Component
    →

    CurrencyInput

    A money amount with a currency symbol, locale formatting, min, max, and step.

  • Component
    →

    Slider

    Pick a value or range along a track.

  • Component
    →

    Input

    Single-line text entry for forms and filters.

  • Component
    →

    TaskBrief

    The brief a person hands an agent before it plans: a goal, one-line "done when" checks, optional spend, time and step limits, allowed tools, model and check-in level.