Skip to content
v0.2.10

NumberInput

A native numeric field with integrated decrement and increment actions.

Preview

Use NumberInput

NumberInput is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
number-input.tsxTSX
"use client";

import { FloodRoot, Field, NumberInput } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <Field label="Seats">
        {(control) => <NumberInput {...control} name="seats" defaultValue={5} min={0} max={20} />}
      </Field>
    </FloodRoot>
  );
}

Design notes

  • Values are finite numbers or null for an empty field. onValueChange reports edits and button/arrow steps; native min/max/step validity remains available. Out-of-bound typed values clamp on blur; a step mismatch remains native validation.
  • Ref and native form attributes target the input. Controlled value stays host-owned; uncontrolled form reset restores the initial value. Buttons use explicit accessible names, which can be translated.
  • Use Field for labels and feedback. Read-only remains selectable and prevents stepping. No currency/locale formatting or wheel interception is supplied. Available in 0.2.5.

API reference

PropValuesDefault
status"error" | "warning" | "success" | "info"—
invalidboolean—
controlSize"sm" | "md" | "lg" | "xl""md"
valuenumber | null—
defaultValuenumber | null0
onValueChange(value: number | null) => void—
minnumber—
maxnumber—
stepnumber1
decreaseLabelstring"Decrease value"
increaseLabelstring"Increase value"
Native HTML propsOmit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "min" | "max" | "step" | "children">Forwarded
View TypeScript source