# Address Avatar

> ENS avatar, or a deterministic gradient for any address.

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

Shows the ENS avatar when the address has one. Otherwise it shows a gradient derived from the address, so the same address always looks the same.

## Installation

```bash
npx shadcn@latest add @0xui/address-avatar
```

ENS avatars resolve on Ethereum mainnet, so mainnet must be in your wagmi config.

## Usage

```tsx
import { AddressAvatar } from "@/components/address-avatar";

<AddressAvatar address={address} size={32} />;
```

The avatar is decorative (`aria-hidden`). Put the name or address next to it as text.

### Headless

```tsx
import { useAddressAvatar, addressGradient } from "@/components/address-avatar";

const { name, avatar } = useAddressAvatar(address);
const background = addressGradient(address); // CSS gradient string
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `address` | `Address` | — | Address to show. |
| `ens` | `boolean` | `true` | Look up the ENS avatar. |
| `src` | `string` | — | Image URL to use instead of the ENS avatar. |
| `size` | `number` | `24` | Diameter in px. |
| `className` | `string` | — | Extra classes on the root. |
