Skip to main content

NFTCard

The NFTCard component is a versatile, responsive card designed to display NFT (Non-Fungible Token) details in your React application. This component supports light and dark themes, includes a like button, and allows users to trigger a buy action.

🛠️ Installation

Ensure you have the necessary packages installed:

  npm i @brightcodeui/beta-ui

Or with Yarn:

yarn add @brightcodeui/beta-ui

🧩 Component Props

PropTypeRequiredDefaultDescription
imageSrcstring"/placeholder.svg"The image URL for the NFT.
titlestring""The title of the NFT.
creatorstring""The name of the NFT creator.
pricestring""The current price of the NFT.
likesnumber🚫0The number of likes the NFT has received.
onBuyClick() => void🚫undefinedCallback function triggered on Buy button click.
classNamestring🚫""Additional CSS classes to customize the component.
theme'light' 'dark'🚫'light'Determines the color theme of the component.

🛠️ Usage Example

🎨 Theming

The theme prop allows you to switch between light and dark modes:

  • Light Theme (Default): bg-white, text-gray-800
  • Dark Theme: bg-gray-800, text-white

Example usage for dark mode:

<NFTCard
imageSrc="https://example.com/nft-dark.jpg"
title="Neon Nights"
creator="CyberArtist"
price="1.2 ETH"
likes={42}
theme="dark"
/>

📚 Storybook Integration

Easily preview and test the component using Storybook:

export const DarkMode: Story = {
args: {
imageSrc: "https://res.cloudinary.com/dphb7gqus/image/upload/v1740226821/Oh6V69milpY3lQJboxJ6--0--rzahe_fsepsi.jpg",
title: "Neon Nights",
creator: "CyberArtist",
price: "1.2 ETH",
likes: 42,
theme: "dark",
},
};

Run Storybook to test your component:

npm run storybook

🚀 Conclusion

The NFTCard component is designed to be flexible and easy to use, making it ideal for showcasing NFTs in your app. You can customize the theme, handle buy actions, and display useful metadata, all within a clean, responsive UI.

Happy coding! 🚀