Number Input

A number with − and + buttons, a range, the reader's currency, unit or percent format, and a label you drag to scrub.

You're using 9. Up to 500 on this plan.

$12.00 × 12$144.00 / month

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/number-input

Usage

import { NumberInput } from "./ui/uicontext/components/NumberInput.ts"
const Message = UiSchema.TaggedEnum({ UpdatedSeats: { seats: Schema.NullOr(Schema.Number) } })export const SeatsInput = (h: Html.H<typeof Message.Type>, seats: number | null) =>	NumberInput(h, {		label: "Seats",		value: seats,		min: 1,		max: 500,		onChange: (next) => Message.UpdatedSeats({ seats: next }),	})

Examples

Formats and states

Currency in German, a unit, a percentage, a big budget with no buttons, read-only, and an error.

Set by your workspace admin.

Scrub

Drag a label left or right to change its value, as in a design tool. The value follows the pointer; it saves once, on release.

Saved 0 times

API reference

Options

NumberInput options
NameTypeDefaultDescription
keystring—Names the field among others in the same view; needed for more than one.
labelrequiredstring—What the number is: "Seats", "Price".
valuerequirednumber | null—The number, or null for an empty field. The caller keeps it.
minnumber——
maxnumber——
stepnumber1What a key, a button press and a dragged pixel change it by; 1 by default.
largeStepnumber—What Shift with an arrow changes it by; ten steps by default.
formatFormat—How it reads, as Intl.NumberFormat options: { style: "currency", currency: "EUR" }, { style: "unit", unit: "kilogram" }, { style: "percent" }, { maximumFractionDigits: 2 }.
localestring—The reader's locale: "de-DE" reads "1.234,5". The browser's by default.
suffixstring—A word after the number that Intl has no unit for: "seats", "per month".
scrubbooleantrueDrag the label to change the value; true by default.
buttonsbooleantrueThe − and + buttons; true by default.
placeholderstring——
descriptionstring——
errorstring——
disabledboolean——
readOnlyboolean——
requiredboolean——
namestring——
onChangerequired(value: number | null) => Message—Each value asked for: while typing, per step and during a scrub. Store it as value.
onCommit(value: number | null) => Message—The value once the person is done: on blur, after a key, on releasing a button or a scrub. Save here.
styleStyle—StyleX styles applied after the field's own.

Source