Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Number Field

A numeric input with decrement/increment steppers, min/max clamping and step.

Quantity: 3 / 10

Installation

npx logic2b@next add number-field

Usage

import { NumberField } from "@/components/ui/number-field"

<NumberField defaultValue={1} min={0} max={10} />

Controlled:

const [value, setValue] = React.useState(3)

<NumberField value={value} onValueChange={setValue} min={0} max={10} />

It renders a real <input type="number">, so it works with native form submission and keyboard entry; the browser’s own spinners are hidden in favor of the styled buttons, which disable themselves at the min/max bounds.

Examples

Step

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<NumberField
  defaultValue={3}
  min={0}
  max={12}
  step={1}
  aria-label="Quantity"
 />

API reference

Generated from the public TypeScript exports in src/ui/number-field.tsx.

View JSON

NumberFieldProps

Type
interface NumberFieldProps extends Omit< React.ComponentProps<"input">, "value" | "defaultValue" | "onChange" | "type" > { value?: number defaultValue?: number onValueChange?: (value: number) => void min?: number max?: number step?: number }

NumberField

Component

A numeric input with decrement/increment steppers, min/max clamping and step. Controlled via `value`/`onValueChange` or uncontrolled via `defaultValue`. Renders a real `<input type="number">` so native form submission and keyboard work; the native spinners are hidden in favor of the styled buttons.

Props: NumberFieldProps
PropTypeRequiredDefaultDescription
valuenumberNo——
defaultValuenumberNo——
onValueChange(value: number) => voidNo——
minnumberNo——
maxnumberNo——
stepnumberNo1—

Accessibility contract

Machine-readable behavior and consumer responsibilities for number-field.

View JSON
Support
Native semantics
Pattern
spinbutton
HTMLInputElement type=number
Keyboard interactions for number-field
KeysBehavior
ArrowUp ArrowDown ArrowLeft ArrowRightMove within the composite control.
EnterCommit typed input according to native number-field behavior.

Built-in semantics

  • The input retains native spinbutton semantics; step buttons are native buttons with labels.

Consumer responsibilities

  • Associate the input with a label and communicate min/max constraints in visible help text.