Currency converter
A converter at today's real exchange rates: type what you send and what they get rolls with it, tap a currency and the whole card springs into a searchable list, and Send says what it did.
…
Loading today's rates…
Things to try
- Type what you send. What they get rolls with it, at today's rate.
- Change a currency. Tap either currency and the card turns into a list of every currency, with a search at the top. Type a code or a name (try "ced"), then pick one with a click or Enter. Picking the currency already on the other side swaps them.
- Swap. The two currencies trade places and the swap button turns.
- Press Send. It turns into Sending, then Sent, and goes back.
Install
npx shadcn@latest add https://your-docs-site/r/currency-converter.jsonDependencies
The install command adds these for you. If you copy the code by hand, install them yourself.
npm install @base-ui/react @hugeicons/core-free-icons @hugeicons/react motionHow it works
- Real data, nothing made up. The rates come from ExchangeRate-API's free endpoint, fetched once and shared by every converter on the page. Currency names come from the browser's
Intl.DisplayNames, decimal places fromIntl.NumberFormat, and each flag is built from the country letters at the start of the currency's code. While the rates load the card says so, and if they can't be reached it offers to try again. - One tray that springs. The card animates its real height to whichever face is showing and clips what's inside, so its edge bounces while text never stretches.
- The label and pill travel. "You send" and the currency pill fly up to become the list's header (
layoutId), blurring slightly on the way; the pill turns into the close button. - Everything else scales in place. The other parts wait at 94% size, blurred and transparent, and spring in with the rows a beat behind each other. Leaving is quicker than arriving. Pressing a pill grows it a little.
- Built on Base UI. Autocomplete handles the search, the keyboard and the list; Escape or the pill closes it and focus returns to where you were.
- Motion does every animation: the tray, the travelling header, the rows, the rolling digits and Send's label.
Send is pretend. Wire your transfer up in
send. ExchangeRate-API's free tier updates daily and asks for the credit shown under the card.Course outline
Modules and lessons joined by lines that stay attached while modules open, lessons get ticked off and finished work drops away.
Filter bar
Filtering card transactions, the way banking and spending apps do it: picking a filter adds a segmented token to the bar, and the transactions, the count and the total spent move to match.