Documentation

Collectible

A component for displaying NFT collectibles with metadata and image support.

Collectible

The Collectible component displays NFT collectibles with automatic metadata resolution and image display.

Usage

import { Collectible } from '@avalabs/builderkit';
 
// Basic usage
<Collectible 
  chain_id={43114}
  address="0x1234567890123456789012345678901234567890"
  token_id={1}
/>
 
// With custom styling
<Collectible 
  chain_id={43114}
  address="0x1234567890123456789012345678901234567890"
  token_id={1}
  className="border-2 rounded-xl"
/>

Props

PropTypeDefaultDescription
chain_idnumber-Chain ID where the NFT exists
addressstring-NFT contract address
token_idnumber-Token ID of the NFT
classNamestring-Additional CSS classes

Features

  • Automatic metadata resolution from IPFS
  • Displays NFT image and name
  • Shows token ID
  • Supports ERC721 standard
  • Responsive layout with fixed dimensions
  • Loading state handling

Examples

Basic NFT Display

<Collectible 
  chain_id={43114}
  address="0x1234567890123456789012345678901234567890"
  token_id={1}
/>

In a Grid Layout

<div className="grid grid-cols-3 gap-4">
  {nfts.map(nft => (
    <Collectible 
      key={nft.token_id}
      chain_id={nft.chain_id}
      address={nft.address}
      token_id={nft.token_id}
    />
  ))}
</div>

With Custom Styling

<Collectible 
  chain_id={43114}
  address="0x1234567890123456789012345678901234567890"
  token_id={1}
  className="shadow-lg hover:shadow-xl transition-shadow"
/>

Component Structure

  1. Container

    • Fixed width of 120px
    • Rounded corners
    • Border
    • Overflow hidden
  2. Image

    • Fixed dimensions (120x120)
    • Maintains aspect ratio
    • Centered display
  3. Info Section

    • White background
    • Token ID display
    • NFT name
    • Proper padding

Metadata Resolution

The component automatically:

  1. Fetches token URI from the contract
  2. Resolves IPFS metadata
  3. Extracts image URL and name
  4. Handles IPFS gateway resolution
Edit on GitHub

Last updated on

On this page