Menu

Number input

Numeric field with steppers. 3 sizes × 3 states.

Installation

$ npx uix-ui@latest add number-input

This copies the file into components/ui/number-input.tsx in your project. npx shadcn@latest add @uix/number-input works too.

Usage

number-input.tsx
import { NumberInput } from "@/components/ui/number-input";

<div style={{ width: 200, maxWidth: "100%" }}>
  <NumberInput label="Tins" defaultValue={2} min={1} max={12} />
</div>

Props

PropTypeDefaultDescription
sizesm | md | lg"md"
labelReact.ReactNode–
secondaryLabelReact.ReactNode–Right-aligned note next to the label, for example "Optional".
feedbackReact.ReactNode–Message under the field.
helperReact.ReactNode–Same as feedback.
errorstring–Error message; also marks the field invalid and replaces the feedback.
valuenumber–Current value (controlled).
defaultValuenumber–
onValueChange(value: number) => void–Called with the new number; the field clamps it to min / max when it loses focus.
leadingAvatarReact.ReactNode–Avatar at the start (for example <Avatar size="xs" initials="AB" />).
leadingIconReact.ReactNode–Icon at the start.
leadingContentReact.ReactNode–Selector or text at the start, for example "Email ▾".
leadingDividerboolean–Hairline after the leading parts.
prefixReact.ReactNode–Fixed text before the value, for example "https://".
tagsReact.ReactNode[]–Tag chips before the value.
suffixReact.ReactNode–Fixed text after the value, for example ".com".
trailingDividerboolean–Hairline before the trailing parts.
trailingContentReact.ReactNode–Action at the end, for example a "Copy" button.
helpIconboolean | string–Help icon; a string becomes its accessible name and tooltip.
trailingIconReact.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-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close