Forms & Inputs
@hacline/ui/number-inputNumberInput
Enter numeric values and adjust them by step increments.
Usage
Omit children for a ready-to-use numeric stepper with built-in increment/decrement controls and keyboard arrow support. On commit, the value is clamped and formatted according to min, max, and step.
Reserve between 1 and 20 seats.
"use client";
import {
Field,
FieldDescription,
FieldLabel,
} from "@/components/ui/hacline/components/field";
import { NumberInput } from "@/components/ui/hacline/components/number-input";
export const Example = () => (
<Field className="w-full max-w-52" name="seat-count">
<FieldLabel>Reserved seats</FieldLabel>
<NumberInput
decrementLabel="Decrease seats"
defaultValue={4}
incrementLabel="Increase seats"
max={20}
min={1}
step={1}
/>
<FieldDescription>Reserve between 1 and 20 seats.</FieldDescription>
</Field>
);Currency Formatting & Stacked Stepper
Format amounts with Intl.NumberFormatOptions, set step={0.01} for decimal precision, and switch to controls="stacked" for a compact trailing stepper suited to forms.
"use client";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
import { NumberInput } from "@/components/ui/hacline/components/number-input";
export const Example = () => (
<Field className="w-full max-w-xs" name="freight">
<FieldLabel>Shipping fee</FieldLabel>
<NumberInput
controls="stacked"
decrementLabel="Decrease shipping fee"
defaultValue={12.5}
format={{ currency: "USD", style: "currency" }}
incrementLabel="Increase shipping fee"
locale="en-US"
min={0}
step={0.01}
/>
</Field>
);Layouts, Variants & Addons
Configure controls ("sides", "stacked", or "none"), variant ("default" or "filled"), size ("sm", "md", "lg"), and inline prefix / suffix units.
px
%
:
"use client";
import { Field, FieldLabel } from "@/components/ui/hacline/components/field";
import { NumberInput } from "@/components/ui/hacline/components/number-input";
export const Example = () => (
<div className="grid w-full max-w-sm gap-4">
<Field name="spacing">
<FieldLabel>Spacing (suffix + stacked)</FieldLabel>
<NumberInput
controls="stacked"
defaultValue={16}
max={128}
min={0}
step={4}
suffix="px"
/>
</Field>
<Field name="discount">
<FieldLabel>Discount (filled + small)</FieldLabel>
<NumberInput
controls="sides"
defaultValue={15}
max={100}
min={0}
size="sm"
suffix="%"
variant="filled"
/>
</Field>
<Field name="port">
<FieldLabel>Port (no stepper controls)</FieldLabel>
<NumberInput
controls="none"
defaultValue={3000}
format={{ useGrouping: false }}
max={65_535}
min={1}
placeholder="3000"
prefix=":"
/>
</Field>
</div>
);Parts
Pass custom children to compose lower-level parts directly.
| Part | Description | Extended Props |
|---|---|---|
NumberInputControl | The text field, which shows the formatted number and takes typing. | — |
NumberInputDecrement | Steps down once, then repeats while held. Shift steps by largeStep. | — |
NumberInputGroup | Holds the input and its buttons. | variantsize |
NumberInputIncrement | Steps up once, then repeats while held. Shift steps by largeStep. | — |
NumberInputScrubArea | Drag across it to change the value. It works anywhere inside the number input, and outside it through controller, like an icon in a toolbar. | — |
NumberInputScrubAreaCursor | Stands in for the mouse cursor while a scrub locks the pointer. Rendered in the body, so transformed ancestors can't move it. | — |
Props
Prop
Type