Multi-chain Swap
Multi-chain Swap: Cross-chain swap widget with chain + token selectors, morphing views, animated flip and quote. Free MIT React & Next.js source with Motion and Tailwind CSS, live preview, CLI install and docs.
Install Multi-chain Swap
npx motion-ui-skill add swapComponents install as source into your project. The interactive page also includes preview, code, documentation and install tabs.
Dependencies
clsxlucide-reactmotionreacttailwind-merge
Source files
components/motion/swap.tsxcomponents/motion/swap/constants.tscomponents/motion/swap/controls.tsxcomponents/motion/swap/data.tscomponents/motion/swap/field.tsxcomponents/motion/swap/quote-row.tsxcomponents/motion/swap/token-badges.tsxcomponents/motion/swap/token-picker.tsxcomponents/motion/swap/types.tscomponents/motion/swap/utils.tslib/ease.tslib/utils.ts
Multi-chain Swap
Cross-chain swap widget with chain + token selectors, morphing views, animated flip and quote.
Install
npx motion-ui-skill add swap
Dependencies
clsxlucide-reactmotionreacttailwind-merge
Usage
"use client";
import { MultiChainSwap } from "@/components/motion/swap";
export function SwapPreview() {
return (
<div className="flex w-full items-center justify-center">
<MultiChainSwap />
</div>
);
}
API Reference
MultiChainSwap
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
chains |
Chain[] |
[ { id: "eth", name: "Ethereum", tone: "bg-primary text-primary-foreground", symbol: "Ξ" }, { id: "sol", name: "Solana", tone: "bg-secondary text-secondary-foreground", symbol: "◎" }, { id: "base", name: "Base", tone: "bg-accent text-accent-foreground", symbol: "B" }, { id: "arb", name: "Arbitrum", tone: "bg-muted text-muted-foreground", symbol: "A" }, { id: "op", name: "Optimism", tone: "bg-destructive text-primary-foreground", symbol: "O" }, { id: "poly", name: "Polygon", tone: "bg-primary/80 text-primary-foreground", symbol: "P" }, { id: "bnb", name: "BNB", tone: "bg-secondary text-secondary-foreground", symbol: "B" }, { id: "avax", name: "Avalanche", tone: "bg-destructive/80 text-primary-foreground", symbol: "A" }, ] |
No | — |
tokens |
Token[] |
[ { id: "eth-eth", symbol: "ETH", name: "Ether", chainId: "eth", balance: 1.245, usd: 3142, popular: true, }, { id: "eth-weth", symbol: "WETH", name: "Wrapped Ether", chainId: "eth", balance: 0.5, usd: 3142, popular: true, }, { id: "eth-usdc", symbol: "USDC", name: "USD Coin", chainId: "eth", balance: 4521, usd: 1, popular: true, }, { id: "eth-usdt", symbol: "USDT", name: "Tether", chainId: "eth", balance: 2100, usd: 1, popular: true, }, { id: "eth-dai", symbol: "DAI", name: "Dai Stablecoin", chainId: "eth", balance: 800, usd: 1, popular: true, }, { id: "eth-wbtc", symbol: "WBTC", name: "Wrapped Bitcoin", chainId: "eth", balance: 0.04, usd: 96000, popular: true, }, { id: "eth-link", symbol: "LINK", name: "ChainLink Token", chainId: "eth", balance: 120, usd: 22, address: "0x51...86ca", trending: true, }, { id: "eth-aztec", symbol: "AZTEC", name: "AZTEC", chainId: "eth", balance: 0, address: "0xa2...62d2", trending: true, }, { id: "eth-cfg", symbol: "CFG", name: "Centrifuge", chainId: "eth", balance: 0, address: "0xcc...8a94", trending: true, }, { id: "eth-ondo", symbol: "ONDO", name: "Ondo", chainId: "eth", balance: 0, address: "0xfa...9be3", trending: true, }, { id: "sol-sol", symbol: "SOL", name: "Solana", chainId: "sol", balance: 12.4, usd: 168, }, { id: "sol-usdc", symbol: "USDC", name: "USD Coin", chainId: "sol", balance: 985.32, usd: 1, }, { id: "base-eth", symbol: "ETH", name: "Ether", chainId: "base", balance: 0.65, usd: 3142, }, { id: "base-usdc", symbol: "USDC", name: "USD Coin", chainId: "base", balance: 1200, usd: 1, }, { id: "arb-arb", symbol: "ARB", name: "Arbitrum", chainId: "arb", balance: 800, usd: 0.95, }, { id: "arb-eth", symbol: "ETH", name: "Ether", chainId: "arb", balance: 0.32, usd: 3142, }, { id: "op-op", symbol: "OP", name: "Optimism", chainId: "op", balance: 450, usd: 2.8, }, { id: "poly-matic", symbol: "MATIC", name: "Polygon", chainId: "poly", balance: 1500, usd: 0.75, }, { id: "bnb-bnb", symbol: "BNB", name: "BNB", chainId: "bnb", balance: 0, usd: 620, }, { id: "avax-avax", symbol: "AVAX", name: "Avalanche", chainId: "avax", balance: 0, usd: 38, }, ] |
No | — |
defaultFromId |
string |
eth-eth |
No | — |
defaultToId |
string |
sol-sol |
No | — |
className |
string |
— | No | — |