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. Usage

Number Field

Usage

NumberField is a number control with minus and plus step buttons around a centered value. Give it a label and it wires the label, description and error like Field; without label it renders the control alone, so pair it with a Label or aria-label.
Compose from the first render
If the field can ever show an error or a description, set label (or description) from the first render and keep it set. NumberField renders the frame alone when none of label, description and error is set and wraps it in the field stack when any is, so a field that gains one after mount gets a new input, which loses focus, the caret and an open draft. NumberField warns once in development when it happens.
Changing the value
  • Buttons. A press takes one step; holding repeats after a pause and speeds up. A mouse press keeps focus where it was, so a typed draft commits with the step.
  • Keys. Arrows step, Shift with an arrow and the Page keys take a large step (largeStep, ten steps by default), Home and End jump to the bounds, Enter commits a draft, Escape reverts it.
  • Typing. The draft accepts digits, the locale's group and decimal symbols, and a minus when min is negative. A valid, in-range, on-step draft applies as you type; the draft snaps to the step grid and clamps on Enter, blur or the next step.
  • Scrub. With scrub, drag the label sideways to change the value one step every few pixels.
Size and layout
The shell is Input's and Field's: the same radius, fill, border and focus, invalid and disabled paint, the same size enum and default (InputSize, Large), and the same heights (--control-height-sm, -md and -lg: 24, 28 and 32px). Like Input it fills its container; constrain it with a class in @layer chroma.overrides. With step buttons the shell is inset 2px around them and the buttons shrink to fit (18, 22 and 26px); without them the value pads its inline axis by --space-8. With a label or description the stack reads label above the shell and description below, 8px apart. The label is 14px (12px at small) and the description 12px in the subtle foreground. See the Pricing story.
Limits
Steps, keys, typed values and scrubbing clamp to min and max. The value strains toward the limit (up at max, down at min, further with each push in a row), the refused button's icon shakes once, and a short note beside the label says what was met. A held button keeps pushing a limit until release. A typed value past a limit also tints the shell with the warning role until the draft recovers or commits. Under reduced motion only a brief color change remains. limitHint={false} hides the note; the polite announcement stays.
Rolling
The value rolls its digits by default. roll={false} shows static formatted text instead: no wheel, no blur and no column or affix motion, with the same caret, draft, semantics and limits.
Description
description sits below the control. Its row opens and closes its height, and when the copy changes only the words that differ rise in and unblur.
Copy
Components ship no literal copy. decrementLabel, incrementLabel, limitNote and valueAnnouncement come from the caller; a step button without its label is not rendered, and the defaults for the note and announcement show the formatted number alone.
Formatting
Locale and formatOptions shape the digits. Fraction digits follow the precision of step and a finite min unless formatOptions sets them. prefix and suffix take copy or a function of the value, and a changing suffix animates per character.
Previous
Navbar / Accessibility
Next
Number Field / API and Development
On this page
Compose from the first render
Changing the value
Size and layout
Limits
Rolling
Description
Copy
Formatting