Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

NumberField

A numeric input with increment and decrement buttons. Supports ranges, steps, and number formatting.

View in Storybook (opens in a new tab)

Installation

import { NumberField } from "@ginga-ui/core";

Basic usage

Limit the range with minValue and maxValue. The arrow keys also change the value.

number-field.tsx
import { NumberField } from "@ginga-ui/core";

export function BasicExample() {
  return (
    <NumberField label="Quantity" defaultValue={1} minValue={0} maxValue={10} />
  );
}

Icons

Pass icons to decrementIcon and incrementIcon to replace the default signs.

number-field.tsx
import { NumberField } from "@ginga-ui/core";
import { Minus, Plus } from "lucide-react";

export function IconExample() {
  return (
    <NumberField
      label="Guests"
      defaultValue={2}
      minValue={1}
      decrementIcon={<Minus />}
      incrementIcon={<Plus />}
    />
  );
}

Formatting

Use formatOptions to format the value, for example as currency. step sets the increment.

Specify in steps of $0.50
number-field.tsx
import { NumberField } from "@ginga-ui/core";

export function FormatExample() {
  return (
    <NumberField
      label="Price"
      defaultValue={15}
      step={0.5}
      formatOptions={{ style: "currency", currency: "USD" }}
      description="Specify in steps of $0.50"
    />
  );
}

Disabled

Pass disabled to disable the field.

number-field.tsx
import { NumberField } from "@ginga-ui/core";

export function DisabledExample() {
  return <NumberField label="Quantity" defaultValue={3} disabled />;
}

Props

NumberField

NameTypeDefaultDescription
labelstring-Label shown above the field.
placeholderstring-Placeholder text of the input.
descriptionReactNode-Help text shown below the field.
errorMessageReactNode | ((validation: ValidationResult) => ReactNode)-Error message shown when the value is invalid.
disabledbooleanfalseDisables the field.
requiredbooleanfalseRequires a value.
readOnlybooleanfalseMakes the field read-only.
invalidbooleanfalseShows the field as invalid.
decrementIconReactNode-Icon of the decrement button. A minus sign is drawn when omitted.
incrementIconReactNode-Icon of the increment button. A plus sign is drawn when omitted.

Also accepts the props of React Aria's NumberField (opens in a new tab).