SwipeUI

Money input

Locale-aware currency entry that reports exact integer minor units while retaining incomplete drafts.

npx @swipeui/cli add money-input
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When to use it

  • Entering prices, transfers, tips or budgets in any currency.
  • Amounts that must be exact, stored as cents or other minor units.
  • Currencies with different decimal places, such as JPY (none) or KWD (three).
  • Forms that need to block submission while an amount is incomplete or out of range.

When not to use it

  • Plain numbers without currency. Use Number field.
  • Selecting from preset amounts. Use Chip group or Radio cards.
  • Displaying amounts. Format them with Text or Slot text.

Installation

Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.

npx @swipeui/cli add money-input
  • Adds components/swipeui/ui/money-format.ts, components/swipeui/ui/money-input.tsx and 15 shared helpers.
  • Installs uniwind, react-native-reanimated, react-native-worklets, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg, react-native-gesture-handler, react-native-safe-area-context. In Expo apps it uses npx expo install so versions match your SDK.

Usage

app/transfer.tsx
import { MoneyInput } from '@/components/swipeui/ui/money-input';

<MoneyInput label="Amount" currency="USD" value={amount} onValueChange={setAmount} />;

Examples

Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.

API reference

MoneyInputProps

PropTypeDefaultDescription
label?string—

Visible label, or inherit an enclosing Field.

helper?string—

Instructions under the field; an error or success message replaces it.

error?string—

Validation message: a destructive ring, an alert glyph, one shake and an error haptic.

success?string—

Confirmation under the field, such as "Username available", in the success colour.

status?FieldStatus'idle'

validating shows a spinner and reports busy; valid draws a check on. An error implies invalid.

required?booleanfalse

Required; "Required" is spoken, and requiredIndicator marks the label. The app owns validation.

requiredIndicator?FieldRequiredIndicator'asterisk'

How a required label is marked: a muted asterisk, the word, or nothing.

optionalIndicator?booleanfalse

Show a muted "Optional" after the label.

disabled?booleanfalse

Disable editing and accessory actions.

disabledStyle?FieldDisabledStyle'muted'

muted lightens the fill and text without opacity; dim lowers the field to 50%.

appearance?FieldAppearance'filled'

The surface: filled (a soft fill), outline (a hairline), underline or ghost (no fill until focused).

size?FieldSize'md'

Height: sm 36pt, md 44pt, lg 52pt.

shape?FieldShape'preset'

preset follows your preset's control radius; pill is a capsule.

labelPlacement?FieldLabelPlacement'above'

above, inset (small, inside at the top), floating (rests centred like a hint and rises on focus or once there's a value) or hidden (spoken only).

focusRing?FieldFocusRing'halo'

The focus indicator: a primary ring with a soft halo, the ring alone, or none.

messageMorph?FieldMessageMorph'fade'

How a changed message arrives: rises in, letter by letter, or at once.

reserveMessageSpace?booleanfalse

Keep one line of room under the field so forms don't move as messages appear.

displayValue?React.ReactNode—

Decorative rendering for an unfocused value; the native text remains the accessible/editable source.

prefix?React.ReactNode—

Decorative prefix or an accessible accessory, drawn first.

suffix?React.ReactNode—

Accessible trailing accessory, drawn last.

leadingIcon?ButtonIcon—

A leading icon: a node, or a function given the state colour and size. It turns primary while focused.

trailingIcon?ButtonIcon—

A trailing icon: a node, or a function given the state colour and size.

clearable?booleanfalse

1.x switch: true means clearButton="always".

clearButton?TextFieldClearButton'never' (or 'always' with `clearable`)

When a "Clear text" button shows.

undoClear?booleantrue

After clearing, the button becomes "Undo clear" for a moment. Phones have no ⌘Z.

undoClearWindow?number4000

How long undo stays, in milliseconds.

counter?TextFieldCounterfalse

A rolling character counter under the field, using maxLength; amber near the limit, red at it.

tintCaret?booleantrue

Caret and selection in the primary colour.

iconTint?"focus" | "none"'focus'

The leading icon turns primary while focused (focus) or stays muted (none).

shakeOnError?booleantrue

Shake once for each new error. Reduce Motion keeps it still.

messages?(Partial<FieldMessages> & Partial<MoneyInputMessages>)MONEY_INPUT_MESSAGES (English)

Built-in strings, for translation. Built-in strings.

nextRef?React.RefObject<_TextInputInstance | null>—

Ref focused when Return is pressed; otherwise a single-line field dismisses.

haptics?boolean | FieldHapticstrue (clear, error and limit)

All feedback, or each part: { clear, error, valid, limit, focus }.

motion?MotionOverridethe app feel

Ring, label and message motion.

className?string—

Classes on the outer field.

controlClassName?string—

Classes on the field surface.

inputClassName?string—

Classes on the editable text.

style?StyleProp<ViewStyle>—

Outer field style.

inputStyle?____TextStyleProp_Internal—

Native editable text style.

value?number | null—

Safe integer minor units, or null for no amount.

defaultValue?number | nullnull

Initial amount in minor units.

onValueChange?((value: number | null) => void)—

Reports valid minor-unit amounts or an empty value.

onValidityChange?((valid: boolean) => void)—

Lets a form block submission while a local draft is incomplete or outside its bounds.

currency?string—

Controlled ISO currency code.

defaultCurrency?string'USD'

Initial currency when uncontrolled.

onCurrencyChange?((currency: string) => void)—

Reports a currency picked from the menu. The amount keeps its minor units; convert it here if needed.

currencies?readonly string[][]

Codes the currency menu offers (up to five). With fewer than two the badge is not a button.

currencyBadge?"flag" | "none" | "symbol"'flag'

The leading badge: a flag and the code, the symbol and the code, or nothing.

amountAlign?"end" | "start"'end'

Where the amount sits in the field.

locale?stringdevice locale

Formatting locale.

min?number—

Minimum minor-unit amount.

max?number—

Maximum minor-unit amount.

Native view/input props not listed here pass through where the exported TypeScript type allows them.

Money input settings

PropDoesDefault
currencyBadgeLeading flag or symbol with the code, or noneflag
currenciesCodes the badge's menu offers, up to fivenone
currency / defaultCurrency / onCurrencyChangeControlled or initial currency, and the pickUSD
amountAlignThe amount at the end or startend
messagesError, badge name and menu headingEnglish

Composition and behavior

  • value is an integer of minor units, or null.
  • currency and locale control formatting; min and max set bounds.
  • The badge before the amount opens a menu of up to five currencies. The amount keeps its minor units when the currency changes, so convert it in onCurrencyChange if you need to.
  • Works on Hermes without formatToParts or Intl.DisplayNames.
  • onValidityChange reports whether the draft is acceptable.

Behavior and gestures

  • Type an amount on a decimal keypad; your draft is kept as typed, even if incomplete, like "12.".
  • When you leave the field, it shows the formatted amount with currency and grouping, such as $1,234.50.
  • Valid amounts are reported as whole minor units, for example 123450 for $1,234.50, so no rounding errors.
  • Out-of-range or incomplete drafts mark the field invalid until fixed.
  • A badge before the amount shows the currency as a flag (or symbol) and its code. With `currencies`, tapping it opens a menu of up to five currencies.

Accessibility

  • Labelled like Text field, with helper and error.
  • The formatted display is decorative; the real number stays readable and editable.
  • Currency and locale follow the device unless you set them.
  • The currency badge is its own button, named "Currency, USD"; its menu items are menu items with the current one selected.

Motion

  • Uses the press motion role, so it follows your app's feel. Pass motion to tune this one instance.
  • The formatted value can roll its digits with Slot text when it changes.

Performance

  • Formatting uses Intl and integer maths only; no floating point.
  • Works on Hermes without `formatToParts` or `Intl.DisplayNames`: the parts are rebuilt from `format()` and names fall back to codes.

Notes for AI

  • Store value as an integer of minor units and pass the ISO currency code.
  • Use onValidityChange to disable Submit while invalid.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items