Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

NumberField

number-field

Edits numeric values with bounds, step buttons, and keyboard stepping.

Usage

Basic usage

±Button stepping, the input box can be typed directly, and the keyboard is supported ↑↓.

tsx
<NumberField aria-label="Quantity" defaultValue={3} />

Scope Limitation

min/max constraint value, the corresponding button is automatically disabled when the boundary is reached.

tsx
<NumberField aria-label="Quantity" defaultValue={0} min={0} max={5} />

Step size

step Set the amount of each increase or decrease, here each step is 5.

tsx
<NumberField aria-label="Step size 5" defaultValue={10} step={5} />

Disabled

disabled Locks the entire control.

tsx
<NumberField aria-label="Quantity" defaultValue={3} disabled />

When to use

Use NumberField for precise numeric input with increment/decrement buttons and min/max bounds, such as quantities or thresholds. Use Slider for approximate values selected by dragging, or Input for arbitrary text.

Import

ts
import { NumberField } from "@hulianui/ui"

Props

NameTypeDefaultDescription
valuenumber|null-Controlled value; null represents empty.
defaultValuenumber|null-Initial value when uncontrolled; null starts empty, matching value.
minnumber-Minimum value.
maxnumber-Maximum value.
stepnumber1Increment or decrement amount.
disabledbooleanfalseDisables interaction.
readOnlybooleanfalseMakes the field read-only.
requiredboolean-Marks the native form field as required.
placeholderstring-Placeholder text shown when the field is empty (forwarded to the inner input).
namestring-Native form name
idstring--
classNamestring--
aria-labelstring-Provided when no title is visible

Events

EventTypeDescription
onValueChange(value: number|null) => voidCalled with the new value. HulianUI intentionally omits Base UI's eventDetails.

Example

tsx
<NumberField aria-label="Quantity" defaultValue={3} min={0} max={5} />

Controlled (value can be null):

tsx
const [v, setV] = useState<number | null>(2);
<NumberField aria-label="Quantity" value={v} onValueChange={setV} min={0} max={10} />

Usage guidelines

  • The controlled type is number | null: clearing emits null, so use state such as useState<number | null> instead of assuming a number is always present. The reverse direction holds too: passing null into value (or defaultValue) renders an empty string with the placeholder visible rather than 0, and min={0} does not clamp it to 0. Tri-state fields (null / 0 / a positive number) such as "leave empty to inherit the default" versus "explicitly zero" can therefore be expressed with this component, and the two stay distinguishable on screen.
  • Controlled usage requires both value and onValueChange. For uncontrolled usage, provide only defaultValue.
  • Values outside the signature are treated as empty rather than falling to 0 (#220). value only accepts number | null, yet controlled values often arrive through type-erased paths (register().value from useForm is unknown, an API payload is any), so an empty string can slip in - and the underlying control renders that as 0, the worst possible landing spot for a tri-state field ("left blank" and "explicitly zero" are opposite business conclusions that then look identical on screen). Such values are now treated as empty, with one warnOnce in development naming the source. undefined is excluded: that means uncontrolled and is passed through untouched.
  • Provide aria-label when there is no visible label so screen readers can identify the field.

Related

Input · Textarea · Select · Checkbox · CheckboxGroup · Radio

Playground

<NumberField defaultValue={3} />
PreviousSliderFormsNextSecretField

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Example
    • Usage guidelines
    • Related
  • Playground