Number fieldPro
A bounded number with steppers that repeat and speed up when held, a strain and a limit note at the edges, typed drafts that spring back to the limit, and digits that roll the way the value moved.
oxyn add number-fieldThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- A bounded number with − and + buttons and a typed field.
- Holding a button repeats after 400 ms, ramping from 150 ms to 40 ms a step (held_steps).
- At a limit a press is refused: the value strains 2–8 px toward the press (further for pushes in a row, capped), the refused button shakes once and a note ("Max 10 seats", built from the prefix and suffix) rises beside the label for 1.5 s.
- A typed draft past a limit tints the shell with the warning role and springs back to the limit on Enter or blur; an unparseable draft reverts.
When not to use
- On or off for things that apply right away: use Switch instead.
- A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself: use Checkbox instead.
- Pick one: use Radio group instead.
Installation
Number field is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add number-fieldUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Seats
Plural suffix; press + at 10 to see the strain and the note.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Price
Prefix, grouping and a step of 50.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Ratio
Decimals from the step; drag the label to scrub.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Small
Small, no limit note.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
NumberField
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | String | — | Label. |
value | f64 | Default::default() | Starting value. |
min | f64 | Default::default() | Lower bound. |
max | f64 | 1e15 | Upper bound. |
step | f64 | 1.0 | Increment (its precision sets the decimals). |
large_step | Option<f64> | Default::default() | PageUp/PageDown and Shift+arrow distance. |
prefix | String | Default::default() | Text before the number ("$"). |
suffix | String | Default::default() | Text after the number (" seats"). |
suffix_one | Option<String> | Default::default() | Singular suffix (" seat") used when the value is 1. |
description | Option<String> | Default::default() | Helper copy under the field. |
size | String | "md" | `sm` · `md` · `lg`. |
scrub | bool | Default::default() | Drag the label sideways to change the value. |
limit_hint | bool | true | Show the limit note. |
grouping | bool | true | Thousands separators. |
disabled | bool | Default::default() | Disabled. |
nowrequired | ClockMs | — | Shared clock (hold-to-repeat and the note's timing). |
on_change | EventHandler<f64> | — | Every committed change. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| ↑or↓ | Step; held keys repeat |
| Shift↑or↓orPage UporDown | Large step |
| HomeorEnd | Min / max |
| Enter | Commit a typed draft (clamped) |
| Escape | Revert the draft |
Accessibility
- The input is role=spinbutton with min, max, now and a valuetext that includes the affixes.
- The limit note is role=status.
- Reduced motion changes the value at once and answers a refused press with a warning tint instead of a shake.
From the spec
- role=spinbutton with aria-valuemin/max/now and a valuetext with the affixes.
- Steppers are tabindex −1 (the keys cover them); the note is role=status.
Motion & interaction
Timing
- Hold repeat: first step on press, then 400 ms, then 150 ms × 0.82 per step down to 40 ms.
- Strain: 260 ms spring (cubic-bezier .3,1.6,.5,1) back from 2 + pushes px (max 8).
- Digits: 220 ms roll up or down per changed place.
- Reduced motion: values change at once; a refused press tints the number with the warning role instead of the strain and shake.
Responsive behaviour
- Widths 164, 196 and 228 px for sm, md and lg.
Edge cases (spec)
- Widths 164 / 196 / 228 px for sm / md / lg.
Notes for AI
- Import
NumberFieldfromoxyn_dioxusand includeSTATUS_INDICATOR_CSSplus the token stylesheet once. - A GPUI version exists:
NumberFieldElinoxyn_gpui. - Props to set first:
label,now. - It reads a clock (
now) for live timers; pass one clock for the whole page rather than one per component. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.