# Number input

A numeric field with increment and decrement controls.

Access: pro. Category: Forms. Kind: primitive.

## When to use

- Use it when a product interface needs a numeric field with increment and decrement controls.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than number input.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Number input

```sh
npx shadcn@latest add @tidal-pro/number-stepper
```

Stylesheets: `components/ui/tidal.css`, `components/ui/number-stepper.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/number-stepper.css";
import{TidalNumberStepper}from"./components/ui/number-stepper";
export default()=><div className="tidal-scope"><TidalNumberStepper label={"Demo"} onValueChange={() => {}} value={1}/></div>;
```

## Structured props

- `TidalNumberDigits.text: string`: Required text value accepted by this exported component.
- `TidalNumberStepper.label: string`: Required label value accepted by this exported component.
- `TidalNumberStepper.onValueChange: (value: number | null) => void`: Callback invoked when the value change interaction is proposed.
- `TidalNumberStepper.value: number | null`: Required value value accepted by this exported component.
- `TidalNumberStepper.decreaseLabel?: string | undefined` (default `Decrease ${label}`): Optional decrease label value accepted by this exported component.
- `TidalNumberStepper.description?: string | undefined`: Optional description value accepted by this exported component.
- `TidalNumberStepper.error?: string | undefined`: Optional error value accepted by this exported component.
- `TidalNumberStepper.formatValue?: ((value: number) => string) | undefined`: Optional format value value accepted by this exported component.
- `TidalNumberStepper.increaseLabel?: string | undefined` (default `Increase ${label}`): Optional increase label value accepted by this exported component.
- `TidalNumberStepper.max?: number | undefined`: Optional max value accepted by this exported component.
- `TidalNumberStepper.min?: number | undefined`: Optional min value accepted by this exported component.
- `TidalNumberStepper.rootClassName?: string | undefined` (default ""): Optional root class name value accepted by this exported component.
- `TidalNumberStepper.step?: number | undefined` (default 1): Optional step value accepted by this exported component.
- `TidalNumberStepper.unit?: string | undefined`: Optional unit value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/number-stepper.tsx) | [Manifest](https://tidalui.com/examples/number-stepper.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useLayoutEffect, useRef, useState } from "react";

import { ArrowUpRight, Check, RotateCcw } from "lucide-react";

import { TidalNumberStepper, TidalNumberDigits } from "./components/ui/number-stepper";

import { TidalButton } from "./components/ui/tidal-button";

import "./components/ui/number-stepper.css";



const tidalExampleStyles = ".tidal-scope .number-stepper-specimen {\n  width: 100%;\n  max-width: 720px;\n  padding: 28px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-card);\n  background: var(--t-surface);\n  box-shadow:\n    0 2px 3px #00000004,\n    0 18px 35px -30px #00000040;\n}\n.tidal-scope .number-stepper-specimen > h3 {\n  font-size: 29px;\n  font-weight: 500;\n  line-height: 1.15;\n  letter-spacing: -1.1px;\n  margin: 15px 0 26px;\n}\n.tidal-scope .number-stepper-specimen > h3 em {\n  font:\n    italic 37px/1.15 \"Instrument Serif\",\n    Georgia,\n    serif;\n  letter-spacing: -0.8px;\n}\n.tidal-scope .number-demo-stage {\n  padding: 7px;\n  margin: 0 -7px;\n  overflow: hidden;\n  transition: height 420ms var(--t-ease-out);\n}\n.tidal-scope .number-demo-content {\n  display: flow-root;\n}\n.tidal-scope .number-demo-workspace {\n  display: grid;\n  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);\n  gap: 28px;\n  align-items: center;\n}\n.tidal-scope .number-demo-workspace form {\n  min-width: 0;\n}\n.tidal-scope .number-demo-form-head {\n  display: flex;\n  justify-content: space-between;\n  gap: 8px;\n  font-size: 11px;\n  letter-spacing: 1.5px;\n  color: var(--t-muted);\n  margin-bottom: 22px;\n}\n.tidal-scope .number-demo-actions {\n  display: flex;\n  gap: 8px;\n  margin-top: 22px;\n}\n.tidal-scope .number-demo-actions .tidal-button {\n  flex: 1;\n  min-width: 0;\n  font-size: 11px;\n  padding: 0 10px;\n}\n.tidal-scope .number-demo-scene {\n  min-width: 0;\n  position: relative;\n  overflow: hidden;\n  border: 1px solid var(--t-ink);\n  border-radius: 12px;\n  padding: 20px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  box-shadow:\n    inset 0 1px 0 #ffffff10,\n    0 12px 18px -12px #0000004a;\n  animation: tidal-number-scene-in 620ms var(--t-ease-out) both;\n}\n.tidal-scope .number-demo-scene-top {\n  display: flex;\n  justify-content: space-between;\n  gap: 8px;\n  font-size: 11px;\n  letter-spacing: 1.4px;\n  opacity: 0.7;\n}\n.tidal-scope .number-demo-capacity {\n  display: flex;\n  align-items: baseline;\n  gap: 8px;\n  margin: 14px 0 20px;\n  min-height: 55px;\n}\n.tidal-scope .number-demo-capacity strong {\n  font-size: 46px;\n  line-height: 1.2;\n  letter-spacing: -1px;\n  font-weight: 500;\n  font-variant-numeric: tabular-nums;\n}\n.tidal-scope .number-demo-capacity > span {\n  font-size: 11px;\n  opacity: 0.72;\n}\n.tidal-scope .number-demo-capacity .number-demo-unset {\n  font-size: 16px;\n  line-height: 1.4;\n  opacity: 1;\n  letter-spacing: -0.3px;\n}\n.tidal-scope .number-demo-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  padding: 0;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  white-space: nowrap;\n  border: 0;\n}\n.tidal-scope .number-demo-slots {\n  display: grid;\n  grid-template-columns: repeat(4, minmax(0, 1fr));\n  gap: 6px;\n  margin-bottom: 16px;\n}\n.tidal-scope .number-demo-slots > span {\n  height: 34px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  position: relative;\n  border: 1px solid color-mix(in srgb, var(--t-surface) 19%, transparent);\n  background: color-mix(in srgb, var(--t-surface) 6%, transparent);\n  border-radius: 6px;\n  color: color-mix(in srgb, var(--t-surface) 40%, var(--t-ink));\n  transform: scale(0.96);\n  transition:\n    transform 320ms var(--t-ease-spring),\n    color 220ms,\n    background 220ms,\n    border-color 220ms;\n}\n.tidal-scope .number-demo-slots > span[data-active] {\n  background: var(--t-surface);\n  color: var(--t-ink);\n  border-color: var(--t-surface);\n  transform: scale(1);\n}\n.tidal-scope .number-demo-slots small {\n  position: absolute;\n  right: 3px;\n  bottom: 2px;\n  font-size: 11px;\n  line-height: 1;\n  opacity: 0.6;\n  font-variant-numeric: tabular-nums;\n}\n.tidal-scope .number-demo-capacity-rail {\n  height: 3px;\n  overflow: hidden;\n  border-radius: 2px;\n  background: color-mix(in srgb, var(--t-surface) 20%, transparent);\n}\n.tidal-scope .number-demo-capacity-rail > span {\n  display: block;\n  height: 100%;\n  width: 100%;\n  background: var(--t-surface);\n  transform-origin: left;\n  transition: transform 420ms var(--t-ease-out);\n}\n.tidal-scope .number-demo-scene-note {\n  font-size: 11px;\n  line-height: 1.6;\n  color: var(--t-surface);\n  opacity: 0.72;\n  margin: 12px 0 0;\n  min-height: 29px;\n}\n.tidal-scope .number-demo-note {\n  font-size: 11px;\n  line-height: 1.6;\n  color: var(--t-muted);\n  margin: 22px 0 0;\n}\n.tidal-scope .number-demo-complete {\n  text-align: center;\n  margin-bottom: 22px;\n  animation: tidal-number-scene-in 420ms var(--t-ease-out) both;\n}\n.tidal-scope .number-demo-complete > span {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 44px;\n  height: 44px;\n  border-radius: 50%;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  margin: 0 auto 12px;\n}\n.tidal-scope .number-demo-complete h4 {\n  font-size: 24px;\n  font-weight: 500;\n  letter-spacing: -0.8px;\n  margin: 0;\n  padding: 5px;\n  outline-offset: -5px;\n}\n.tidal-scope .number-demo-complete p {\n  font-size: 11px;\n  line-height: 1.6;\n  margin: 8px 0 0;\n  color: var(--t-muted);\n}\n.tidal-scope\n  .number-stepper-specimen[data-phase=\"planned\"]\n  .number-demo-workspace {\n  display: block;\n  max-width: 340px;\n  margin: auto;\n}\n.tidal-scope .number-stepper-specimen[data-phase=\"planned\"] .number-demo-slots {\n  display: none;\n}\n.tidal-scope .number-demo-adjust {\n  display: flex;\n  justify-content: center;\n  gap: 10px;\n  margin-top: 22px;\n}\n.tidal-scope .number-demo-adjust .tidal-button {\n  font-size: 11px;\n}\n.tidal-scope .number-demo-adjust > button:last-child {\n  width: 44px;\n  height: 44px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  border: 1px solid var(--t-border);\n  border-radius: 10px;\n  background: var(--t-subtle);\n  color: var(--t-ink);\n}\n.tidal-scope .number-demo-actions > button:focus-visible,\n.tidal-scope .number-demo-adjust > button:focus-visible {\n  outline-offset: -5px;\n  outline-color: currentColor;\n}\n@keyframes tidal-number-scene-in {\n  from {\n    opacity: 0;\n    translate: 0 10px;\n  }\n  to {\n    opacity: 1;\n    translate: 0 0;\n  }\n}\n@media (max-width: 620px) {\n  .tidal-scope .number-stepper-specimen {\n    padding: 18px;\n  }\n  .tidal-scope .number-stepper-specimen > h3 {\n    font-size: 25px;\n    margin: 10px 0 18px;\n  }\n  .tidal-scope .number-stepper-specimen > h3 em {\n    font-size: 32px;\n  }\n  .tidal-scope .number-demo-workspace {\n    grid-template-columns: minmax(0, 1fr);\n    gap: 20px;\n  }\n  .tidal-scope .number-demo-form-head {\n    display: none;\n  }\n  .tidal-scope .number-demo-scene {\n    padding: 14px;\n  }\n  .tidal-scope .number-demo-capacity {\n    margin: 10px 0 12px;\n    min-height: 45px;\n  }\n  .tidal-scope .number-demo-capacity strong {\n    font-size: 38px;\n  }\n  .tidal-scope .number-demo-slots {\n    grid-template-columns: repeat(6, minmax(0, 1fr));\n    gap: 5px;\n    margin-bottom: 12px;\n  }\n  .tidal-scope .number-demo-note {\n    margin-top: 8px;\n  }\n  .tidal-scope .number-demo-scene-note {\n    min-height: 0;\n  }\n}\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .number-demo-slots > span {\n    transform: none;\n  }\n}";

export function NumberStepperDemo() {
  const [members, setMembers] = useState<number | null>(6),
    [error, setError] = useState("");
  const [phase, setPhase] = useState<"editing" | "planning" | "planned">(
      "editing",
    ),
    [height, setHeight] = useState<number>();
  const input = useRef<HTMLInputElement>(null),
    title = useRef<HTMLHeadingElement>(null),
    content = useRef<HTMLDivElement>(null),
    restore = useRef(false);
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
  const focusOwner = useRef<HTMLElement | null>(null);
  const valid =
    members !== null &&
    Number.isInteger(members) &&
    members >= 1 &&
    members <= 12;
  const amount = valid ? members! : 0,
    hours = amount * 8;
  useEffect(() => () => clearTimeout(timer.current), []);
  useLayoutEffect(() => {
    const active = document.activeElement;
    const canMoveFocus =
      active === document.body || active === focusOwner.current;
    if (phase === "planned" && canMoveFocus) {
      title.current?.focus({ preventScroll: true });
      focusOwner.current = null;
    } else if (phase === "editing" && restore.current) {
      restore.current = false;
      if (canMoveFocus) {
        input.current?.focus({ preventScroll: true });
        input.current?.select();
      }
      focusOwner.current = null;
    }
  }, [phase]);
  useLayoutEffect(() => {
    const node = content.current;
    if (!node) return;
    const measure = () => {
      const css = getComputedStyle(node.parentElement!);
      setHeight(
        node.offsetHeight +
          Number.parseFloat(css.paddingTop) +
          Number.parseFloat(css.paddingBottom),
      );
    };
    measure();
    const ro = new ResizeObserver(measure);
    ro.observe(node);
    return () => ro.disconnect();
  }, []);
  function edit() {
    clearTimeout(timer.current);
    focusOwner.current =
      document.activeElement instanceof HTMLElement
        ? document.activeElement
        : null;
    setError("");
    restore.current = true;
    setPhase("editing");
    if (phase === "editing") {
      restore.current = false;
      input.current?.focus({ preventScroll: true });
      input.current?.select();
    }
  }
  function reset() {
    setMembers(6);
    edit();
  }
  return (
    <div className="number-stepper-specimen" data-phase={phase}>
      <div className="number-demo-stage" style={{ height }}>
        <div ref={content} className="number-demo-content">
          {phase === "planned" ? (
            <div className="number-demo-complete">
              <span aria-hidden="true">
                <Check size={21} />
              </span>
              <h4 ref={title} tabIndex={-1}>
                Room for {amount}.
              </h4>
              <p>
                This is a local sample plan. No people were invited or resources
                booked.
              </p>
            </div>
          ) : null}
          <div className="number-demo-workspace">
            {phase !== "planned" ? (
              <form
                noValidate
                onSubmit={(event) => {
                  event.preventDefault();
                  if (!valid) {
                    setError("Choose a whole number from 1 to 12.");
                    input.current?.focus({ preventScroll: true });
                    return;
                  }
                  focusOwner.current =
                    (event.nativeEvent as SubmitEvent).submitter instanceof
                    HTMLElement
                      ? (event.nativeEvent as SubmitEvent).submitter
                      : document.activeElement instanceof HTMLElement
                        ? document.activeElement
                        : null;
                  setError("");
                  setPhase("planning");
                  timer.current = setTimeout(() => setPhase("planned"), 600);
                }}
              >
                <div className="number-demo-form-head">
                  <span>THE QUANTITY</span>
                  <span>01 / 12</span>
                </div>
                <TidalNumberStepper
                  ref={input}
                  label="Contributors"
                  name="contributors"
                  value={members}
                  onValueChange={(next) => {
                    setMembers(next);
                    setError("");
                  }}
                  min={1}
                  max={12}
                  step={1}
                  unit={members === 1 ? "contributor" : "contributors"}
                  required
                  description="One to twelve. Eight sample hours each."
                  error={error}
                  disabled={phase === "planning"}
                />
                <div className="number-demo-actions">
                  <TidalButton
                    type="button"
                    variant="secondary"
                    onClick={() => (phase === "planning" ? edit() : reset())}
                  >
                    {phase === "planning" ? "Cancel plan" : "Reset sample"}
                  </TidalButton>
                  <TidalButton type="submit" loading={phase === "planning"}>
                    Plan sample
                    <ArrowUpRight size={13} aria-hidden="true" />
                  </TidalButton>
                </div>
              </form>
            ) : null}
            <aside
              className="number-demo-scene"
              aria-label="Sample daily capacity"
            >
              <div className="number-demo-scene-top">
                <span>DAILY CAPACITY</span>
                <span>N / 027</span>
              </div>
              <div className="number-demo-capacity">
                {valid ? (
                  <>
                    <strong>
                      <span className="number-demo-sr">
                        {hours} contributor-hours per day
                      </span>
                      <TidalNumberDigits text={String(hours)} />
                    </strong>
                    <span aria-hidden="true">hours</span>
                  </>
                ) : (
                  <span className="number-demo-unset">
                    Choose a whole quantity.
                  </span>
                )}
              </div>
              <div className="number-demo-slots" aria-hidden="true">
                {Array.from({ length: 12 }, (_, i) => (
                  <span
                    key={i}
                    data-active={i < amount || undefined}
                    style={{
                      transitionDelay: `${Math.abs(i - amount) < 3 ? Math.abs(i - amount) * 25 : 0}ms`,
                    }}
                  >
                    <svg
                      width="17"
                      height="17"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      strokeWidth="1.6"
                    >
                      <circle cx="12" cy="8" r="3" />
                      <path
                        d="M6 20v-2a6 6 0 0 1 12 0v2"
                        strokeLinecap="round"
                      />
                    </svg>
                    <small>{String(i + 1).padStart(2, "0")}</small>
                  </span>
                ))}
              </div>
              <div className="number-demo-capacity-rail" aria-hidden="true">
                <span style={{ transform: `scaleX(${amount / 12})` }} />
              </div>
              <p
                className="number-demo-scene-note"
                role={phase === "planning" ? "status" : undefined}
              >
                {phase === "planning"
                  ? "Planning the local sample…"
                  : phase === "planned"
                    ? "A sample plan, ready to adjust."
                    : valid
                      ? `${amount} ${amount === 1 ? "contributor" : "contributors"} × 8 hours. Your sample capacity.`
                      : "Use a whole number from 1 to 12."}
              </p>
            </aside>
          </div>
          {phase === "planned" ? (
            <div className="number-demo-adjust">
              <TidalButton variant="secondary" onClick={edit}>
                Adjust sample
              </TidalButton>
              <button
                type="button"
                onClick={reset}
                aria-label="Reset original quantity"
              >
                <RotateCcw size={15} />
              </button>
            </div>
          ) : null}
        </div>
      </div>
      <p className="number-demo-note">
        Fictional contributors and capacity. Nothing is booked, invited or
        stored.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <NumberStepperDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Required visible label, controlled value:number|null and onValueChange(number|null); initialize with useState<number|null>(initialValue). A real type=number input retains native ref/name/required/disabled/readOnly/form/typing/validation, native onInput/onChange/focus/blur/invalid handlers, and unmodified ArrowUp/Down/Home/End/Enter behavior. null represents empty; nonfinite caller values render empty and invalid without mutating caller state. Optional finite min/max; nonfinite bounds are omitted. step(default1) must be positive/finite or falls back1. Reversed finite bounds disable the field/controls and expose linked configuration feedback. Native min/max/step validity is reflected in aria-invalid after hydration and user edits; consumer error also links an alert. Pointer/Enter/Space step buttons use a detached native input probe for precise decimal step-grid and boundary behavior; only onValueChange is called for button steps, without forging native change events or mutating the real input. Actual native step availability includes a maximum that is off the step grid. Boundary buttons remain focusable with aria-disabled and make no change; disabled/readOnly disables both. PageUp/Down and Shift+ArrowUp/Down step ten increments, compose with native onKeyDown and honor preventDefault/modifier keys and composition guards. No wheel override, hold-to-repeat or label scrubbing is introduced. Optional unit, formatValue(number), localizable decreaseLabel/increaseLabel, description/error, className(input) and rootClassName. Native typing is shown while focused; an aria-hidden tabular digit display rolls while unfocused, with a readable truncated fallback for long formatted values. Full formatted value/unit is exposed through aria-valuetext, and help/error IDs merge with caller aria-describedby; empty values describe the unit once, and numeric values include it only in aria-valuetext. Consumer native onChange only receives actual input changes; use onValueChange for all numeric updates. Native editing may temporarily produce null/badInput or out-of-range/off-step numbers; the consumer owns validation and submission. Reduced motion resolves digit, feedback and press states immediately. No wrapper form, network work, storage or booking is introduced.
