BuzzForm
BuzzFormDocs

Number Field

Numeric input with steppers, formatting, and constraints.

Number Field

The number field provides numeric input with increment/decrement buttons, formatting options, and min/max constraints.

Installation

pnpm dlx shadcn@latest add https://form.buildnbuzz.com/r/number.json

Usage

import { createSchema } from "@buildnbuzz/buzzform";
import { Form } from "@/components/buzzform/form";

const schema = createSchema([
  {
    type: "number",
    name: "quantity",
    label: "Quantity",
    min: 1,
    max: 100,
    defaultValue: 1,
  },
]);

export function NumberFieldDemo() {
  return <Form schema={schema} onSubmit={console.log} />;
}

Properties

PropTypeDefaultDescription
minnumber-Minimum value
maxnumber-Maximum value
precisionnumber-Decimal places

UI Options

OptionTypeDefaultDescription
ui.stepnumber1Increment/decrement amount
ui.variant'default' | 'stacked' | 'pill' | 'plain''default'Stepper button style
ui.prefixstring-Prefix text (e.g., "$")
ui.suffixstring-Suffix text (e.g., "kg")
ui.thousandSeparatorboolean | stringfalseFormat with separators
ui.hideSteppersbooleanfalseHide +/- buttons
ui.copyablebooleanfalseShow copy button

Features

Stepper Variants

// Default - buttons on sides
{ type: "number", name: "qty", ui: { variant: "default" } }

// Stacked - buttons stacked vertically
{ type: "number", name: "qty", ui: { variant: "stacked" } }

// Pill - compact pill-style buttons
{ type: "number", name: "qty", ui: { variant: "pill" } }

// Plain - no stepper buttons
{ type: "number", name: "qty", ui: { variant: "plain" } }

Prefix & Suffix

Add context to numeric values:

{
  type: "number",
  name: "price",
  label: "Price",
  precision: 2,
  ui: { prefix: "$" },
}

{
  type: "number",
  name: "weight",
  label: "Weight",
  ui: { suffix: "kg" },
}

Thousand Separator

Format large numbers with separators:

{
  type: "number",
  name: "salary",
  label: "Annual Salary",
  ui: {
    prefix: "$",
    thousandSeparator: true, // Uses locale default
  },
}

// Custom separator
{
  type: "number",
  name: "amount",
  ui: { thousandSeparator: " " }, // Space separator
}

Examples

Price Input

{
  type: "number",
  name: "price",
  label: "Price",
  required: true,
  min: 0,
  max: 10000,
  precision: 2,
  ui: {
    prefix: "$",
    thousandSeparator: true,
    variant: "plain",
  },
}

Quantity Selector

{
  type: "number",
  name: "quantity",
  label: "Quantity",
  min: 1,
  max: 99,
  defaultValue: 1,
  ui: {
    step: 1,
    variant: "pill",
  },
}

Percentage Input

{
  type: "number",
  name: "discount",
  label: "Discount",
  min: 0,
  max: 100,
  precision: 1,
  ui: {
    suffix: "%",
    step: 5,
  },
}

Weight with Decimals

{
  type: "number",
  name: "weight",
  label: "Weight",
  min: 0,
  precision: 2,
  ui: {
    suffix: "kg",
    step: 0.1,
    variant: "stacked",
  },
}

On this page