Number Input
Numbers only, for shares, units and counts, with an optional Max and clear.
No `format`: digits and one decimal mark, no grouping.
- value
- —
`format="quantity"`: thousands separators, up to 4 decimals.
- formattedValue
- —
- value
- —
- floatValue
- —
You might be looking for:
- Input
Single-line text entry.
- Textarea
Multi-line text entry.
- Currency Input
Money with a currency symbol and optional picker.
- Date Picker
Pick a calendar date from a popover.
NumberInput only takes numbers: digits, one decimal mark and (with
allowNegative) a minus. Anything else never reaches the field. Money is
Currency Input, which adds the
currency symbol, two decimals and the currency picker.
Formats
format | Grouping | Decimals | Use for |
|---|---|---|---|
| omitted | none | any (or decimalScale) | Plain numbers |
quantity | thousands | up to 4 | Shares, units |
integer | thousands | none | Counts, years |
onValueChange receives three fields:
| Field | Example | Use for |
|---|---|---|
formattedValue | "12,344.5" | What the user sees in the field |
value | "12344.5" | Form state / API payload (no separators) |
floatValue | 12344.5 | Math, without parsing yourself |
Store value in React state or React Hook Form and pass it back with
valueIsNumericString. Separators follow locale (the browser's when
omitted); value stays dot-decimal either way.
Examples
Shares with Max
One trailing control: a Max chip replaces the clear affordance.
125.5 shares held
Quantity
Units and share counts, up to four decimal places.
Up to four decimal places.
Validation error
The error ring and halo come from the wrapping Field.
React Hook Form
Store the unformatted numeric string (values.value) in form state and
pass valueIsNumericString so separators are not double-applied.
Playground
<Field> <NumberInput format="quantity" value={value} onValueChange={…} valueIsNumericString onClear={…}> <InputGroupButton variant="chip" size="xs">Max</InputGroupButton> </NumberInput></Field>Usage
import { Field, FieldLabel } from "@sophic/portal-ui/components/ui/field";
import { InputGroupButton } from "@sophic/portal-ui/components/ui/input-group";
import { NumberInput } from "@sophic/portal-ui/components/ui/number-input";
<Field>
<FieldLabel htmlFor="shares">Shares</FieldLabel>
<NumberInput
id="shares"
format="quantity"
value={shares}
valueIsNumericString
onValueChange={(next) => setShares(next.value)}
onClear={() => setShares("")}
>
<InputGroupButton variant="chip" size="xs">Max</InputGroupButton>
</NumberInput>
</Field>NumberInput is the row only: it always lives inside a
Field, which carries the card, focus ring, and
error state. The one trailing control is children, else the clear from
onClear.
variant="tall" is one --button-height-lg row, the same height as Input
variant="tall" and Button size="lg". Drop the
Field's vertical padding when you use it, so the card does not grow past that.
For a convenience wrapper, see useNumberInput in
@sophic/portal-ui/lib/use-number-input.
Props
Also accepts native <input> attributes except type, onChange and
inputMode.
Prop
Type
Default
onValueChange payload
Prop
Type
Default
Changelog
- 8 October 2026: numbers only; the
currencyformat andprefixmoved to Currency Input, and rawonChangemode is gone. Full notes - 20 August 2026 — “You might be looking for” also maps to Date Picker. Full notes
- 19 August 2026 — “You might be looking for” map to Input and Textarea. Full notes
- 4 August 2026 — Optional
formatprop merges format-as-you-type masking into Number Input (currency,quantity,integerpresets). Full notes - 22 July 2026 — Max chip matches the currency picker pill. Full notes
- 22 July 2026 — Invalid state colors the message only (amount stays normal). Full notes
- 15 July 2026 — Currency chip is
SelectTrigger variant="chip". Full notes - 15 July 2026 — Added (display-type amount row with clear affordance). Full notes