Componentdata1.21 KB gzipZero dependencies

Exchange Rate

Exchange rate converter with two-way live calculation.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add exchange-rate

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { ExchangeRate } from "@/components/ui/exchange-rate"; <ExchangeRate />

Source code

exchange-rate.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxexchange-rate.tsx99 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface ExchangeRateProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {  rates?: Record<string, number>;  defaultFrom?: string;  defaultTo?: string;} const RATE_TABLE: Record<string, number> = { TRY: 1, USD: 0.029, EUR: 0.027, GBP: 0.023 }; function convert(amount: number, from: string, to: string, rates: Record<string, number>): number {  const f = rates[from] ?? 1;  const t = rates[to] ?? 1;  if (f === 0) return 0;  return (amount / f) * t;

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { ExchangeRate } from "@/components/ui/exchange-rate"; <ExchangeRate />
PropTypeDescription
ratesRecord<string, number>Configures rates. (Default: RATE_TABLE)
defaultFromstringConfigures default from. (Default: "TRY")
defaultTostringConfigures default to. (Default: "USD")