@usevyre/react@usevyre/vue

Number Input

A controlled numeric input with −/+ stepper buttons. It emits a realnumber (or null when empty) — never a string or an event — so it drops straight intoForm without parsing.


Stepper, min/max & precision

Use the buttons or type directly. / step bystep; hold Shift for ×10. Values clamp tomin/max on blur.

Quantity (1–99, step 1)

Price (step 0.5, 2 decimals)

Total: 9.99

import { useState } from "react";
import { NumberInput, Stack, Text } from "@usevyre/react";

const [qty, setQty] = useState<number | null>(1);
const [price, setPrice] = useState<number | null>(9.99);

<Stack direction="column" gap="lg">
  <Stack direction="column" gap="xs">
    <Text size="sm" color="muted">Quantity (1–99, step 1)</Text>
    <NumberInput value={qty} onChange={setQty} min={1} max={99} />
  </Stack>
  <Stack direction="column" gap="xs">
    <Text size="sm" color="muted">Price (step 0.5, 2 decimals)</Text>
    <NumberInput
      value={price}
      onChange={setPrice}
      min={0}
      step={0.5}
      precision={2}
    />
  </Stack>
</Stack>

Inside a Form

Because onChange emits a number, NumberInputworks in FormField with no glue code — the numeric value lands in form state and validation rules like min apply directly.

import { Form, FormField, NumberInput, Button } from "@usevyre/react";

<Form onSubmit={(v) => save(v)}>
  <FormField name="age" label="Age" rules={{ required: true, min: 18 }}>
    <NumberInput min={0} max={120} />
  </FormField>
  <Button type="submit" variant="primary">Continue</Button>
</Form>

Props

Props

PropTypeDefaultDescription
valuenumber | nullControlled value. null = empty. Omit for uncontrolled.
defaultValuenumber | nullnullInitial value when uncontrolled.
onChange(value: number | null) => voidEmits the parsed number, or null when empty. NOT an event.
minnumberMinimum; clamped on blur.
maxnumberMaximum; clamped on blur.
stepnumber1Increment/decrement amount.
precisionnumberDecimal places to round to.
size"sm" | "md" | "lg""md"Control size.
disabledbooleanfalseDisable input and steppers.
readOnlybooleanfalseRead-only (no stepping/typing).