Skip to content
Sign upPro
Apps SDKCurrency widgetMenu

Currency widget (Pro)

ProIncluded in $99

A conversion you can work with: both amounts are fields, swap turns the pair, and the rate says how fresh it is.

ProType in either amount, swap the pair, or pick another currency. The rate says how fresh it is.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/currency-widget

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { CurrencyWidget } from "@/components/ui/chatcn/pro/currency-widget"

<CurrencyWidget
  rates={{ USD: 1, EUR: 0.862, JPY: 151.2 }}
  defaultFrom="EUR"
  defaultTo="JPY"
  defaultAmount={250}
  updatedAt={fetchedAt}
  history={eurJpyLastMonth}
  fee={0.0175}
/>

Pass rates against any common base and the widget works out each pair. Both amounts are fields: type in either and the other follows, with each currency's own decimals (no cents on yen). The menus are native selects, so they work well on phones; picking the currency already on the other side swaps them. Under the amounts the rate shows with its freshness: a green Live while it is younger than staleAfter minutes, an amber Delayed after. history draws the month as a small line in green or red with its change, and flips when the pair is swapped. fee adds what would arrive after a card or transfer fee.

Examples

States

ProDelayed rates with a falling month, and a plain pair with no history.

Props

PropTypeNotes
ratesRecord<string, number>Units per one unit of a common base
defaultFrom, defaultTo, defaultAmountThe starting pair and amount
updatedAt, staleAfterDate | string, numberFreshness; default 15 minutes
historynumber[]The starting pair's rate, oldest first
feenumberA fraction, such as 0.0175
currenciesstring[]Codes in the menus. Default all in rates
title, meta, localeHeader and formatting
labelsPartial<CurrencyWidgetLabels>Every string, for translation

Keyboard

KeyAction
TabCurrency, amount, swap, then the other side
EnterFinish typing an amount

Accessibility

  • Amounts are labelled with their currency; menus with their side.
  • Freshness is said in words as well as color, and the history has its change in its label.

Motion

The swap arrow turns half a circle per swap over 300 ms; the live dot pulses. Reduced motion stills both.