Alphaonchain-ui is experimental. Components, docs, and registry URLs may change before a stable release.
onchain-ui
Components

Address Display

Displays an EVM wallet address with copy-to-clipboard and an optional block explorer link.

Use AddressDisplay anywhere you need a compact wallet identity primitive in tables, cards, account headers, transaction rows, and activity feeds.

Loading...
address-display.tsxShow code
import { AddressDisplay } from "@/components/ui/address-display"export function AddressDisplayDemo() {  return (    <AddressDisplay address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />  )}

Installation

npx shadcn add https://onchain-ui.dev/r/address-display.json
Open in

Requirements

Add <Toaster /> from sonner to your root layout so copy feedback can show a toast.

import { Toaster } from "@/components/ui/sonner"

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Toaster />
      </body>
    </html>
  )
}

Dependencies

The registry item uses viem, sonner, and lucide-react by default.

npm install viem sonner lucide-react

The icons are replaceable. If your app uses another icon set, pass copyIcon and explorerIcon and keep the same component API.

import { Copy01Icon, LinkSquare02Icon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
import { AddressDisplay } from "@/components/ui/address-display"

<AddressDisplay
  address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
  copyIcon={<HugeiconsIcon icon={Copy01Icon} className="size-3 shrink-0" />}
  explorerIcon={
    <HugeiconsIcon icon={LinkSquare02Icon} className="size-3 shrink-0" />
  }
/>

Usage

import { AddressDisplay } from "@/components/ui/address-display"

<AddressDisplay address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />

Pass chainId to link to a known chain's explorer: Ethereum (1), Optimism (10), Polygon (137), Base (8453), and Arbitrum (42161). Without a chainId, explorer links point to Etherscan. For other chains, pass a full explorerUrl.

Examples

With Base Explorer

Pass chainId to link to a known chain's explorer, or explorerUrl for any other chain.

Loading...
address-display-base.tsxShow code
import { AddressDisplay } from "@/components/ui/address-display"export function AddressDisplayWithExplorer() {  return (    <AddressDisplay      address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"      chainId={8453}    />  )}

Full Address

Disable truncation to show the full address. Full addresses can wrap in narrow containers, so prefer the default truncated display in dense layouts.

Loading...
address-display-full.tsxShow code
import { AddressDisplay } from "@/components/ui/address-display"export function AddressDisplayFull() {  return (    <AddressDisplay      address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"      truncate={false}      showExplorer={false}    />  )}

Copy Only

Hide the explorer link when you just need clipboard copy.

Loading...
address-display-copy-only.tsxShow code
import { AddressDisplay } from "@/components/ui/address-display"export function AddressDisplayCopyOnly() {  return (    <AddressDisplay      address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"      showExplorer={false}    />  )}

Props

PropTypeDefaultDescription
addressAddress-EVM wallet address (required)
labelReactNodeTruncated addressDisplay label. The copied value is always the underlying address
truncatebooleantrueTruncate the address
truncateCharsnumber4Characters shown at each end when truncated
showCopybooleantrueShow copy-to-clipboard button
showExplorerbooleantrueShow block explorer link
chainIdnumber | null1EVM chain id used to pick a known block explorer
explorerUrlstringDerived from chainIdFull explorer URL override for this address
copyIconReactNodeLucide copy iconIcon rendered before the address when copy is enabled
explorerIconReactNodeLucide external link iconIcon rendered for the explorer link
classNamestring-Applied to the root wrapper
addressClassNamestring-Applied to the address text or copy trigger

On this page