Number input
Numeric field with steppers. 3 sizes × 3 states.
import { NumberInput } from "@/components/ui/number-input";
export default function Example() {
return (
<div style={{ width: 200, maxWidth: "100%" }}>
<NumberInput label="Tins" defaultValue={2} min={1} max={12} />
</div>
);
}
Installation
$ npx uix-ui@latest add number-inputThis copies the file into components/ui/number-input.tsx in your project. npx shadcn@latest add @uix/number-input works too.
Usage
import { NumberInput } from "@/components/ui/number-input";
<div style={{ width: 200, maxWidth: "100%" }}>
<NumberInput label="Tins" defaultValue={2} min={1} max={12} />
</div>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | sm | md | lg | "md" | |
label | React.ReactNode | – | |
secondaryLabel | React.ReactNode | – | Right-aligned note next to the label, for example "Optional". |
feedback | React.ReactNode | – | Message under the field. |
helper | React.ReactNode | – | Same as feedback. |
error | string | – | Error message; also marks the field invalid and replaces the feedback. |
value | number | – | Current value (controlled). |
defaultValue | number | – | |
onValueChange | (value: number) => void | – | Called with the new number; the field clamps it to min / max when it loses focus. |
leadingAvatar | React.ReactNode | – | Avatar at the start (for example <Avatar size="xs" initials="AB" />). |
leadingIcon | React.ReactNode | – | Icon at the start. |
leadingContent | React.ReactNode | – | Selector or text at the start, for example "Email ▾". |
leadingDivider | boolean | – | Hairline after the leading parts. |
prefix | React.ReactNode | – | Fixed text before the value, for example "https://". |
tags | React.ReactNode[] | – | Tag chips before the value. |
suffix | React.ReactNode | – | Fixed text after the value, for example ".com". |
trailingDivider | boolean | – | Hairline before the trailing parts. |
trailingContent | React.ReactNode | – | Action at the end, for example a "Copy" button. |
helpIcon | boolean | string | – | Help icon; a string becomes its accessible name and tooltip. |
trailingIcon | React.ReactNode | – | Icon at the end. |
Everything else is passed to the root element, so className, aria-* and event handlers work as usual.
Dependencies
Installed for you by the CLI.
class-variance-authorityclsxtailwind-merge
lib/utils.tscomponents/ui/icons.tsx