# Token Icon

> Token logo with fallbacks and an optional chain badge.

- Install: `npx shadcn@latest add @0xui/token-icon`
- Registry JSON: https://0xui.io/r/token-icon.json
- Source: https://github.com/fimbul-lab/0xui/blob/main/registry/default/components/token-icon.tsx

Tries three sources in order: your `src` URL (a token list's `logoURI`; `ipfs://` works), the built-in icon for the symbol, then the symbol's first two letters. List logos go dead often, so each step falls through to the next.

## Installation

```bash
npx shadcn@latest add @0xui/token-icon
```

## Usage

```tsx
import { TokenIcon } from "@/components/token-icon";

<TokenIcon symbol="USDC" />;

// With a token list
<TokenIcon symbol={token.symbol} src={token.logoURI} />;
```

## Examples

### With chain badge

The same token on different chains is easy to mix up. `chainId` adds the chain's logo in the corner.

```tsx
<TokenIcon symbol="USDC" chainId={8453} size={40} />
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `symbol` | `string` | — | Token symbol. Used for the built-in icon, the fallback and the accessible label. |
| `src` | `string` | — | Logo URL, e.g. `token.logoURI`. Takes priority over the built-in icon. |
| `gateway` | `string` | `https://ipfs.io/ipfs/` | IPFS gateway for `ipfs://` logos. |
| `chainId` | `number` | — | Show this chain's logo as a corner badge. |
| `size` | `number` | `24` | Diameter in px. |
| `variant` | `"background" \| "branded" \| "mono"` | `"branded"` | Style of the built-in icons. |
