CurrencySwap

A two-way converter. Type an amount and the result eases to its value; the swap button turns the pair around. Finance.

Open playground
They get€92.00

1 USD = 0.92 EUR

Illustrative rates

About

CurrencySwap is a React component in the Finance category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CurrencySwap } from "@ashutoshswamy/smoui" and set rates, defaultFrom, defaultAmount.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CurrencySwap } from "@ashutoshswamy/smoui";

<CurrencySwap rates={{ USD: 1, EUR: 0.92, JPY: 151.2 }} defaultFrom="USD" defaultTo="EUR" />

Props 3

rates

Units of each currency per one unit of a common base. Only the ratios matter.

Record<string, number>
defaultFrom / defaultTo

Starting pair.

string
defaultAmount

Starting amount.

numberdefault 100