Ravi Katiyar

Swap Card

Cards 107

About

swap-card This file contains the reusable SwapCard component. It uses framer-motion for the layout animations, lucide-react for icons, and is styled with shadcn/ui principles.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Swap Card to your project and fits it to your theme.

Code

How Swap Card is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

// demo.tsx
import { SwapCard, type Token } from "@/components/ui/swap-card";
import { Coins, PiggyBank } from "lucide-react"; // Example icons

// Define the tokens with their data and icons
const tokens: Token[] = [
  {
    symbol: "ETH",
    name: "Ethereum",
    icon: Coins,
  },
  {
    symbol: "AAVE",
    name: "Aave",
    icon: PiggyBank,
  },
];

export default function SwapCardDemo() {
  const handleSwap = (data: { sellAmount: string; buyAmount: string; sellToken: Token; buyToken: Token }) => {
    console.log("Swap Initiated:", {
      from: `${data.sellAmount} ${data.sellToken.symbol}`,
      to: `${data.buyAmount} ${data.buyToken.symbol}`,
    });
    // Add your swap logic here (e.g., API call)
  };

  return (
    <div className="min-h-screen bg-background flex items-center justify-center p-4">
      <SwapCard
        tokens={tokens}
        initialSellToken={tokens[0]} // ETH
        initialBuyToken={tokens[1]} // AAVE
        onSwap={handleSwap}
      />
    </div>
  );
}

Dependencies

More by Ravi Katiyar

View all
  • Animated Shader Hero

    Animated Shader Hero

    3.7K
  • Hero

    Hero

    3.1K
  • Circular Gallery

    Circular Gallery

    2.7K
  • Minimalist Hero

    Minimalist Hero

    2.5K
  • Floating Icons Hero Section

    Floating Icons Hero Section

    1.9K
  • Glass Calendar

    Glass Calendar

    1.8K
  • Feature Carousel

    Feature Carousel

    1.7K
  • AI Image Generator Hero

    AI Image Generator Hero

    1.4K

More in Cards

View all
  • Statistics Card 2

    Statistics Card 2

    263
  • Stats cards with links

    Stats cards with links

    39
  • Card

    Card

    70
  • Course Design Cards

    Course Design Cards

    1.1K
  • The Item one

    The Item one

    3
  • Card Studio

    Card Studio

    7
  • Statistics Card 7

    Statistics Card 7

    292
  • Item

    Item

    10