Pure UI
DocsComponentsBlocksNEW
132

Docs

IntroductionGet Started
Installation
Theming

Components

AccordionAvatarBadgeButtonButton GroupCalendarCardCheckboxCollapsibleCombobox
Detached Triggers
DialogInputInput GroupInput OTPKbdLabelMenuNumber FieldPopoverRadio GroupNEWScroll AreaSelectSeparatorSheetSpinnerSwitchTabsNEWTextareaToastTooltip

Number Field

A numeric input element with increment and decrement buttons, and a scrub area.

Installation

Loading content...

Usage

import {
  NumberField,
  NumberFieldDecrement,
  NumberFieldGroup,
  NumberFieldIncrement,
  NumberFieldInput,
  NumberFieldScrubArea,
} from "@/components/ui/number-field";
import { Label } from "@/components/ui/label";
<NumberField defaultValue={0} id="quantity">
  <NumberFieldScrubArea>
    <Label htmlFor="quantity">Quantity</Label>
  </NumberFieldScrubArea>
  <NumberFieldGroup>
    <NumberFieldDecrement />
    <NumberFieldInput />
    <NumberFieldIncrement />
  </NumberFieldGroup>
</NumberField>

Design

Default

Together

Up Down

Examples

With Scrub

If you want to allow the user to scrub the input value with mouse wheel, you can pass allowWheelScrub={true} prop to NumberField component while focused on the input.

<NumberField
  allowWheelScrub
>
  // rest of the code
</NumberField>

Disabled

Range

You can pass min and max props to NumberField component to set the range of the input value.

Step

You can pass step prop to NumberField component to set the step of the input value.

Controlled

Value: 0

Formatting