Introducing PrimeReact v11-alpha 🎉Discover Now

InputNumber

InputNumber is used to enter numeric values.

Current stock count for this item
preview

Installation#

npx shadcn@latest add @primereact/inputnumber

Usage#

import { InputNumber } from '@/components/ui/inputnumber';
<InputNumber />

Examples#

Basic#

A numeric input supporting formatted values, step control, and boundaries.

basic-demo

Numerals#

InputNumber supports decimal numbers with precision control.

numerals-demo

Locale#

Localization information such as grouping and decimal symbols are defined with the locale property which defaults to the user locale.

locale-demo

Currency#

Monetary values are enabled by setting mode property as currency. In this setting, currency property also needs to be defined using ISO 4217 standard such as "USD" for the US dollar.

currency-demo

Prefix & Suffix#

Custom texts e.g. units can be placed before or after the input section with the prefix and suffix properties.

prefix-suffix-demo

Buttons#

Spinner buttons can be customized with InputGroup and IconField compositions.

buttons-demo

Vertical#

Buttons can also be placed vertically.

vertical-demo

Filled#

Specify the variant property as filled to display the component with a higher visual emphasis than the default outlined style.

filled-demo

Float Label#

A floating label appears on top of the input field when focused. Visit FloatLabel documentation for more information.

float-label-demo

Ifta Label#

IftaLabel is used to create infield top aligned labels. Visit IftaLabel documentation for more information.

ifta-label-demo

Sizes#

InputNumber provides small and large sizes as alternatives to the base by setting the size property.

sizes-demo

Invalid#

Invalid state is displayed using the invalid prop to indicate a failed validation. This style is useful when integrating with form validation libraries.

invalid-demo

Disabled#

When disabled is present, the element cannot be edited and focused.

disabled-demo

API#

Sub-Components#

See Primitive API for InputNumberRoot component documentation.

Hooks#

See Headless API for useInputNumber hook documentation.

Accessibility#

See InputNumber Primitive for WAI-ARIA compliance details and keyboard support.