# Currency input

Enter an exact decimal amount with native forms and locale-aware currency context.

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

## When to use

- Use it when a product interface needs enter an exact decimal amount with native forms and locale-aware currency context.
- 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 currency 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 Currency input

```sh
npx shadcn@latest add @tidal-pro/currency-input
```

Stylesheets: `components/ui/tidal.css`, `components/ui/currency-input.css`.

## Minimal example

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

## Structured props

- `TidalCurrencyInput.currency: string`: Required currency value accepted by this exported component.
- `TidalCurrencyInput.label: ReactNode`: Required label value accepted by this exported component.
- `TidalCurrencyInput.onValueChange: (value: string) => void`: Callback invoked when the value change interaction is proposed.
- `TidalCurrencyInput.value: string`: Required value value accepted by this exported component.
- `TidalCurrencyInput.aria-disabled?: Booleanish | undefined`: Accessible disabled supplied by the consumer.
- `TidalCurrencyInput.aria-invalid?: boolean | "true" | "false" | "grammar" | "spelling" | undefined`: Accessible invalid supplied by the consumer.
- `TidalCurrencyInput.currencyDisplay?: "symbol" | "name" | "code" | "narrowSymbol" | undefined` (default "symbol"): Optional currency display value accepted by this exported component.
- `TidalCurrencyInput.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCurrencyInput.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalCurrencyInput.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalCurrencyInput.locale?: string | undefined`: Optional locale value accepted by this exported component.
- `TidalCurrencyInput.max?: string | undefined`: Optional max value accepted by this exported component.
- `TidalCurrencyInput.maximumFractionDigits?: number | undefined`: Optional maximum fraction digits value accepted by this exported component.
- `TidalCurrencyInput.min?: string | undefined`: Optional min value accepted by this exported component.
- `TidalCurrencyInput.minimumFractionDigits?: number | undefined`: Optional minimum fraction digits value accepted by this exported component.
- `TidalCurrencyInput.onChange?: ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined`: Callback invoked when the change interaction is proposed.
- `TidalCurrencyInput.onInput?: InputEventHandler<HTMLInputElement> | undefined`: Callback invoked when the input interaction is proposed.
- `TidalCurrencyInput.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalCurrencyInput.rootClassName?: string | undefined` (default ""): Optional root class name value accepted by this exported component.
- `TidalCurrencyInput.step?: string | undefined`: Optional step value accepted by this exported component.

## Complete usage example

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

```tsx
"use client";

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

import { useId, useState } from "react";

import { TidalCurrencyInput } from "./components/ui/currency-input";

import "./components/ui/currency-input.css";



const tidalExampleStyles = ".tidal-scope .currency-input-demo {\n  container: currency-input-demo / inline-size;\n  display: grid;\n  gap: 20px;\n  width: min(100%, 520px);\n  min-width: 0;\n  color: var(--t-ink);\n}\n\n.tidal-scope .currency-input-demo-actions {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 10px;\n}\n\n.tidal-scope .currency-input-demo-actions > button {\n  min-width: 132px;\n  min-height: 44px;\n  padding: 10px 15px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 13px;\n  font-weight: 650;\n  cursor: pointer;\n  transition:\n    border-color 140ms,\n    background-color 140ms,\n    color 140ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .currency-input-demo-actions > button[type=\"submit\"] {\n  border-color: var(--t-ink);\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .currency-input-demo-actions > button:hover {\n  border-color: var(--t-ink);\n}\n\n.tidal-scope .currency-input-demo-actions > button[type=\"reset\"]:hover {\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .currency-input-demo-actions > button:active {\n  transform: scale(0.98);\n}\n\n.tidal-scope .currency-input-demo-actions > button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n.tidal-scope .currency-input-demo-status {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n@container currency-input-demo (max-width: 320px) {\n  .tidal-scope .currency-input-demo-actions {\n    display: grid;\n    grid-template-columns: minmax(0, 1fr);\n  }\n\n  .tidal-scope .currency-input-demo-actions > button {\n    width: 100%;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .currency-input-demo-actions > button {\n    transition: none;\n  }\n\n  .tidal-scope .currency-input-demo-actions > button:active {\n    transform: none;\n  }\n}";

const INITIAL_AMOUNT = "1248.50";

export function CurrencyInputDemo() {
  const generatedId = useId().replace(/:/g, "");
  const [amount, setAmount] = useState(INITIAL_AMOUNT);
  const [error, setError] = useState<string | null>(null);
  const [status, setStatus] = useState("Edit the sample amount.");

  return (
    <form
      className="currency-input-demo"
      aria-label="Currency input preview"
      onSubmit={(event) => {
        event.preventDefault();
        const submitted = new FormData(event.currentTarget).get("amount");
        setError(null);
        setStatus(`Prepared USD ${String(submitted)} locally.`);
      }}
      onReset={(event) => {
        if (event.defaultPrevented) return;
        setAmount(INITIAL_AMOUNT);
        setError(null);
        setStatus("Sample reset.");
      }}
    >
      <TidalCurrencyInput
        id={`${generatedId}-amount`}
        name="amount"
        label="Invoice amount"
        value={amount}
        onValueChange={(nextValue) => {
          setAmount(nextValue);
          setError(null);
          setStatus("Edit the sample amount.");
        }}
        currency="USD"
        locale="en-US"
        minimumFractionDigits={2}
        maximumFractionDigits={2}
        min="0"
        max="250000"
        step="0.01"
        description="Sample invoice amount."
        error={error}
        placeholder="0.00"
        autoComplete="off"
        required
        onInvalid={(event) => {
          event.preventDefault();
          setError(event.currentTarget.validationMessage);
          setStatus("Check the amount.");
          event.currentTarget.focus({ preventScroll: true });
        }}
      />

      <div className="currency-input-demo-actions">
        <button type="submit">Prepare sample</button>
        <button type="reset">Reset</button>
      </div>
      <p
        className="currency-input-demo-status"
        role="status"
        aria-live="polite"
      >
        {status}
      </p>
    </form>
  );
}

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

```

## Gotchas

- Keep field state, validation results, submission, and persistence in the host form workflow.

## 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}

{"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."}

Controlled exact decimal string value and onValueChange; required currency plus optional locale/currencyDisplay/fraction display bounds. Optional canonical decimal min/max/step use string arithmetic without floating-point conversion; step may be any and bases at min or zero. Native text-input name/form/required/autocomplete/placeholder/handlers/className/style and forwarded ref remain available; type/inputMode/value/defaultValue/min/max/step and disabled/readOnly ARIA are owned. The named visible input serializes the exact canonical string. Locale digits, distinct decimal/group separators, minus and currency tokens normalize to the canonical decimal proposal; a period remains the canonical decimal during direct editing even when it is also the locale grouping token. The visible formatted output uses Intl.NumberFormat while the input retains an editable exact string. Caller onInput/onChange run first and either may prevent a paired proposal. Consumer errors, native invalid attributes, disabled/readOnly and unprevented native reset semantics are preserved. Consumers own state, validation policy beyond exact decimal bounds, form submission and all financial behavior.
