|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +--- |
| 4 | + |
| 5 | +import React from "react"; |
| 6 | +import { Address } from "@scaffold-ui/components"; |
| 7 | +import { DocsProvider } from "../../components/DocsProvider"; |
| 8 | + |
| 9 | +# Address Component |
| 10 | + |
| 11 | +The `Address` component displays Ethereum addresses with automatic ENS resolution, avatar display, and block explorer linking. |
| 12 | + |
| 13 | +## Import |
| 14 | + |
| 15 | +```tsx |
| 16 | +import { Address } from "@scaffold-ui/components"; |
| 17 | +``` |
| 18 | + |
| 19 | +## Props |
| 20 | + |
| 21 | +| Prop | Type | Default | Description | |
| 22 | +| -------------------- | ---------------------------------------------------------- | --------- | ---------------------------------------- | |
| 23 | +| `address` | `Address` | - | The Ethereum address to display | |
| 24 | +| `disableAddressLink` | `boolean` | `false` | Disable linking to block explorer | |
| 25 | +| `format` | `"short" \| "long"` | `"short"` | Display format for the address | |
| 26 | +| `size` | `"xs" \| "sm" \| "base" \| "lg" \| "xl" \| "2xl" \| "3xl"` | `"base"` | Size of the component | |
| 27 | +| `onlyEnsOrAddress` | `boolean` | `false` | Show only ENS name or address (not both) | |
| 28 | +| `chain` | `Chain` | `mainnet` | Blockchain network for resolution | |
| 29 | + |
| 30 | +## Live Examples |
| 31 | + |
| 32 | +### Basic Usage |
| 33 | + |
| 34 | +<DocsProvider> |
| 35 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" /> |
| 36 | +</DocsProvider> |
| 37 | + |
| 38 | +```tsx twoslash |
| 39 | +import React from "react"; |
| 40 | +import { Address } from "@scaffold-ui/components"; |
| 41 | + |
| 42 | +<Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="base" />; |
| 43 | +``` |
| 44 | + |
| 45 | +### Different Sizes |
| 46 | + |
| 47 | +<DocsProvider> |
| 48 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="xs" /> |
| 49 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="sm" /> |
| 50 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="base" /> |
| 51 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="lg" /> |
| 52 | + <Address address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" size="xl" /> |
| 53 | +</DocsProvider> |
| 54 | + |
| 55 | +```tsx twoslash |
| 56 | +import React from "react"; |
| 57 | +import { Address } from "@scaffold-ui/components"; |
| 58 | + |
| 59 | +<Address |
| 60 | + address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" |
| 61 | + size="xs" |
| 62 | + // ^? |
| 63 | +/>; |
| 64 | +``` |
| 65 | + |
| 66 | +### Long Format |
| 67 | + |
| 68 | +<DocsProvider> |
| 69 | + <Address |
| 70 | + address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" |
| 71 | + format="long" |
| 72 | + size="base" |
| 73 | + /> |
| 74 | +</DocsProvider> |
| 75 | + |
| 76 | +```tsx twoslash |
| 77 | +import React from "react"; |
| 78 | +import { Address } from "@scaffold-ui/components"; |
| 79 | + |
| 80 | +<Address |
| 81 | + address="0x1234567890123456789012345678901234567890" |
| 82 | + format="long" |
| 83 | + size="base" |
| 84 | +/>; |
| 85 | +``` |
| 86 | + |
| 87 | +### Disable Block Explorer Link |
| 88 | + |
| 89 | +<DocsProvider> |
| 90 | + <Address |
| 91 | + address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" |
| 92 | + disableAddressLink={true} |
| 93 | + size="base" |
| 94 | + /> |
| 95 | +</DocsProvider> |
| 96 | + |
| 97 | +```tsx twoslash |
| 98 | +import React from "react"; |
| 99 | +import { Address } from "@scaffold-ui/components"; |
| 100 | + |
| 101 | +<Address |
| 102 | + address="0x1234567890123456789012345678901234567890" |
| 103 | + disableAddressLink={true} |
| 104 | + size="base" |
| 105 | +/>; |
| 106 | +``` |
| 107 | + |
| 108 | +### ENS or Address Only |
| 109 | + |
| 110 | +<DocsProvider> |
| 111 | + <Address |
| 112 | + address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" |
| 113 | + onlyEnsOrAddress={true} |
| 114 | + size="base" |
| 115 | + /> |
| 116 | +</DocsProvider> |
| 117 | + |
| 118 | +```tsx twoslash |
| 119 | +import React from "react"; |
| 120 | +import { Address } from "@scaffold-ui/components"; |
| 121 | + |
| 122 | +<Address |
| 123 | + address="0xd8da6bf26964af9d7eed9e03e53415d37aa96045" |
| 124 | + onlyEnsOrAddress={true} |
| 125 | + size="base" |
| 126 | +/>; |
| 127 | +``` |
| 128 | + |
| 129 | +### Custom Chain |
| 130 | + |
| 131 | +```tsx twoslash |
| 132 | +import React from "react"; |
| 133 | +import { polygon } from "viem/chains"; |
| 134 | +import { Address } from "@scaffold-ui/components"; |
| 135 | + |
| 136 | +<Address |
| 137 | + address="0x1234567890123456789012345678901234567890" |
| 138 | + chain={polygon} |
| 139 | + size="base" |
| 140 | +/>; |
| 141 | +``` |
0 commit comments