ExchangeRateChip

"1 USD = 0.9214 EUR" as a chip. The rate eases to each update, the chip washes green or red for a beat, and a change pill turns with its sign. Finance.

Open playground
1 USD =0.9214EUR0.00%1 USD equals 0.9214 EUR

About

ExchangeRateChip 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 { ExchangeRateChip } from "@ashutoshswamy/smoui" and set from, rate, previous among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<ExchangeRateChip from="USD" to="EUR" rate={rate} />

Props 5

from / to

ISO currency codes.

string
rate

How many `to` one `from` buys.

number
previous

Rate a moment ago. Left out, the chip compares with the last rate it saw.

number
decimals

Defaults to 4, or 2 for rates of 100 and up.

number
swappable

Show the button that flips the pair.

booleandefault true