Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Number Field
  3. API and Development

Number Field

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import NumberField, NumberFieldLimitEdge, NumberFieldSize from @prepared911/ui/number-field.
PropTypeDefaultNotes
value, defaultValuenumber | nulluncontrolled, nullnull is empty.
onValueChange(value, details) => voidReasons: input-change, keyboard-step, item-press, press-hold, drag, drag-cancel, form-reset. Cancelable except drag-cancel and form-reset.
min, maxnumber | stringunboundedClamp every path. A finite min starts the step grid; a negative min allows a minus in the draft.
stepnumber | string1Grid for snapping. "any" removes snapping and steps by 1.
largeStepnumberten stepsShift+Arrow, PageUp, PageDown.
label, description, error, invalidSetting label, description or error wraps the control in the field stack. error shows while invalid or aria-invalid is true.
decrementLabel, incrementLabelLocalizedMessageAccessible names of the step buttons; a button is not rendered without its name.
prefix, suffixLocalizedMessage | (value) => LocalizedMessageRendered through the rolling digits.
localestringruntime localeDigits, draft symbols and speech, as in Text value mode. Pass it explicitly when a server-rendered page must match the client.
formatOptionsIntl.NumberFormatOptionsderived from step and min
rollbooleantruefalse shows the value as static formatted text: no wheel, no blur and no column or affix enter or exit motion. The caret, draft, semantics and limits are unchanged.
scrubbooleanfalseDrag the label sideways to change the value. Needs label.
limitHintbooleantrueShows the note beside the label.
limitNote(edge, formattedLimit) => LocalizedMessageformatted limit
valueAnnouncement(formattedValue, edge) => LocalizedMessageformatted valuePolite live region after a button step or a limit.
sizeInputSizeLarge
Every other native input attribute (name, form, required, disabled, readOnly, id, aria-*) goes to the input. name submits the canonical number through a hidden input.
Input purpose
autoComplete and name are typed with the shared InputPurposeProps. The visible input renders inputMode="numeric" ("decimal" when the step or bounds allow fractions), spellCheck={false} and autoComplete="off"; an autoComplete token you pass, such as bday-year, replaces off. name is submitted through a hidden input that carries the canonical number, not the formatted text.
Props
NameTypeDefaultDescription
autoCompleteHTMLInputAutoCompleteAttribute—Autofill purpose token. Set it on every field that collects information about the user: name, email, tel, street-address, postal-code, username, current-password, new-password, one-time-code, or a section and shipping or billing prefix before one. Input turns spellcheck off for identifier purposes. Do not pass off to a field that collects personal data; no design-system control defaults to it except NumberField, which a token replaces.
classNamestring—Classes appended after the generated classes. Put overrides in @layer chroma.overrides.
decrementLabelLocalizedMessage—Accessible name of the decrement button. The button is not rendered without it.
defaultValuenumber | null—Initial value when uncontrolled. Drives {@link useControlled } and form reset restoration.
descriptionLocalizedMessage—Supporting copy below the control, linked with aria-describedby.
errorLocalizedMessage—Error copy below the control while {@link invalid} is true, linked with aria-errormessage.
formatOptionsNumberFormatOptions—Intl.NumberFormat options for the displayed value. They win over the fraction digits derived from step and min.
incrementLabelLocalizedMessage—Accessible name of the increment button. The button is not rendered without it.
invalidboolean—When true, the control paints the invalid edge and exposes aria-invalid. aria-invalid on its own does the same.
labelLocalizedMessage—Visible label above the control. Setting it (or description or error) wraps the control in a field stack that wires the label, description and error to the input. Without it, NumberField renders the control alone and the caller supplies a Label or aria-label; the limit note then has no label to sit beside.
largeStepnumber—Distance of a large step (Shift+Arrow, PageUp, PageDown). Defaults to ten steps.
limitHintbooleantrueWhether the note beside the label appears when a limit is met. The polite announcement is unaffected.
limitNoteNumberFieldLimitNoteCopy—Copy for the limit note. Defaults to the formatted limit alone.
localestring—BCP 47 locale for the digits, the group and decimal symbols a draft accepts, and speech. Defaults to the runtime locale, as Text's value mode does, so a server-rendered app that must match the client passes it explicitly.
maxstring | number—Upper bound. Typed values, steps and scrubbing clamp to it. Unbounded when omitted.
minstring | number—Lower bound. Typed values, steps and scrubbing clamp to it. Unbounded when omitted. The step grid starts here when it is finite, and a negative min lets the draft take a minus sign.
namestring—Form control name, submitted with the form. Browsers also read it as an autofill hint, so pass a meaningful one.
onValueChange((value: number | null, details: ChangeDetails<NumberFieldValueChangeReason>) => void)—Called for every value change, including controlled mode and form reset.
placeholderLocalizedMessage—Placeholder copy when the field is empty.
prefixNumberFieldAffix—Text before the value, inside the control.
refRef<HTMLInputElement>—Ref to the rendered input.
rollbooleantrueRoll the digits to each new value, and animate the affix characters as they change. false shows the value as static formatted text: no wheel, no blur and no column or affix enter or exit motion. The caret, the draft, the spinbutton semantics and the limits behave the same either way.
scrubbooleanfalseWhen true, dragging the label sideways changes the value one step every few pixels. Past a limit the value follows the pointer with rubber-band resistance and springs back on release. The label click after a drag is suppressed.
sizeInputSize—Control scale. Defaults to {@link InputSize.Large}.
stepstring | number—Distance between values. Typed drafts snap to this grid on commit, and fraction digits default to its precision. Defaults to 1. "any" removes snapping and steps by 1.
suffixNumberFieldAffix—Text after the value, inside the control.
valuenumber | null—Controlled numeric value. undefined on the first render is uncontrolled; null is a controlled empty value.
valueAnnouncementNumberFieldValueAnnouncementCopy—Copy for the live announcement after a button step or a limit. Defaults to the formatted value alone.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Number Field / Usage
Next
Number Field / Accessibility
On this page
Input purpose
Props
Storybook