HomeDocsComponentsBlocksChartsThemes
Introduction
  • Introduction
  • Installation
  • Themes
  • llms.txt
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Amount
  • Aspect Ratio
  • Audio Player
  • Avatar
  • Avatar Upload
  • Badge
  • Banner
  • Breadcrumb
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Code Block
  • Collapsible
  • Color Picker
  • Combobox
  • Command
  • Context Menu
  • Copy Button
  • Countdown
  • Data Grid
  • Data Table
  • Date Picker
  • Date Range Picker
  • Description List
  • Device Mockup
  • Dialog
  • Direction
  • Dot Loader
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • File Upload
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Label
  • Menubar
  • Meter
  • Multi Select
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Password Strength
  • Phone Input
  • Popover
  • Progress
  • Progress Circle
  • Radio Group
  • Rating
  • Resizable
  • Responsive Dialog
  • Rich Text Editor
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature
  • Skeleton
  • Slider
  • Sonner
  • Sortable
  • Spinner
  • Stat
  • Stepper
  • Switch
  • Table
  • Tabs
  • Tag Input
  • Terminal
  • Textarea
  • Time Field
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tree
  • Typography
  • Video Player
  • Window Mockup
AI
  • Message Scroller
  • Message
  • Bubble
  • Marker
  • Attachment
  • Questionnaire
  • Composer
  • Reasoning
  • Tool Call
  • Approval Card
  • Citations
Blocks
  • Airtable
  • Airtable Kanban
  • ClickUp List
  • ClickUp Kanban
  • Repeatable Group
  • Command Palette
  • Sign In and Sign Up
  • Availability Scheduler
  • AI Chat
  • Action Bar
  • Notion
  • Banking
  • Lineup Builder
  • Sports Score
  • Strava
  • Sheets
  • Notices
  • Settings
  • Billing
Utilities
  • motion
  • sounds
  • scroll-fade
  • shimmer
Another UI. Built on shadcn/ui with Phosphor icons.

Number Field

PreviousNext

A number input with minus and plus buttons, keyboard and wheel stepping, bounds, and formatting for currency, percent and units.

Base UIReact AriaRadix UI
Radix UI

Between 1 and 99. Hold a button to keep counting.

Up to 50%. Arrow keys step 1%, Shift steps 10%.

Total $254.15

Installation#

pnpm dlx shadcn@latest add https://anotherui.dev/r/number-field.json

Usage#

import { NumberField } from "@/components/ui/number-field"
<NumberField defaultValue={1} min={1} max={99} aria-label="Quantity" />
 
<NumberField
  value={price}
  onValueChange={setPrice}
  min={0}
  step={0.5}
  formatOptions={{ style: "currency", currency: "CAD" }}
/>
 
<NumberField
  defaultValue={0.15}
  min={0}
  max={1}
  step={0.01}
  formatOptions={{ style: "percent" }}
/>

Keyboard#

  • Arrow Up and Arrow Down. Step by step. Hold Shift to step by largeStep.
  • Page Up and Page Down. Step by largeStep, ten steps by default.
  • Home and End. Jump to min and max when they are set.
  • Enter. Commits what was typed. In a form, it still submits.
  • Wheel. Steps only while the field has focus, so the page keeps scrolling.

Props#

  • value, defaultValue, onValueChange. The number, or null when the field is empty. Use it controlled or not.
  • min, max, step. Bounds and step size. Typed values are clamped to the bounds and rounded to the decimals the step or the format shows when the field loses focus. The buttons turn off at the bounds.
  • largeStep. The step for Page Up, Page Down and Shift with an arrow.
  • formatOptions, locale. Passed to Intl.NumberFormat for the value shown when the field is not being edited. With style: "percent" the value is a fraction, so 0.15 shows as 15% and is typed as 15.
  • prefix, suffix. Text or an icon inside the field, beside the number.
  • disabled, readOnly, aria-invalid. Behave like an input. An invalid field gets the destructive ring.
Navigation MenuPagination

On This Page

InstallationUsageKeyboardProps