Skip to main content
CurrencyField ← Back to Table of Contents

Summary

Revolut-style currency input: locale-aware formatting, digit animations, optional currency picker, and minor-unit storage.

Basic usage

Fixed currency (PLN)

Multi-currency with picker


State & storage

Minor units

Amounts are stored as the smallest currency unit (e.g. grosze, cents). Commas, spaces, and currency symbols are display only. Multi-currency state:

Hydration (normalizeState)

On load, the field normalizes incoming values:
  • 6666660 (int) → Treated as minor units → 6666660
  • 66666.60 (float) → Treated as major units → converted to 6666660
  • "12.50" (string with .) → Major units → 1250

Configuration API

All methods accept Closure unless noted.

min() / max()

Defined in major units (e.g. 10.50) but validated internally as minor units.

Custom database formats

By default, CurrencyField saves minor units as integers. If your database uses decimals, override dehydration:

Store major units (decimal)

Map at the model layer to keep form logic clean:

Real-world examples

Product price in a resource

Multi-currency donation form


Playground

/admin/flex-fields-playground/currency-field See Playground for setup.

CSS classes (reference)


Performance

Payload vs SSR trade-offs

Keep small multi-currency pickers inline for simplest HTML. Use a large whitelist only when needed — the registry path avoids repeating dozens of symbol/name/locale objects inside every field’s x-data.