onchain-ui
Components

Network logo

Displays a network or chain logo from an EVM chain id.

Pass a supported chainId to NetworkLogo to show its built-in logo. Use showTooltip to display the network name on hover.

Loading...
network-logo.tsxShow code
import { NetworkLogo } from "@/components/ui/network-logo"export function NetworkLogoDemo() {  return <NetworkLogo chainId={8453} showTooltip />}

Installation

npx shadcn add @onchain-ui/network-logo
Open in

Requirements

This component uses the shadcn tooltip. The install adds components/ui/tooltip.tsx if it is missing, or uses your existing file. Wrap your app with TooltipProvider to enable tooltips.

Usage

import { NetworkLogo } from "@/components/ui/network-logo"

<NetworkLogo chainId={8453} />

NetworkLogo ships with built-in logos for common EVM networks. Use src only when you need to override a logo or support a chain that is not built in yet.

Without a logo, the component uses the symbol, name, or chain ID as fallback text, in that order. A chain ID must fit in full. The limit is 3 characters at xs and sm, and 4 at larger sizes. Longer IDs show ? because truncating an ID could identify a different chain. Pass fallback to supply your own content or showTooltip to show the full ID on hover.

Names and symbols for common networks are built in. Anything else comes from the chains in Configuration, so a chain you added to your wagmi config renders with its name here too.

See Icon resolution for the lookup order and fallback rules.

Supported chains

ChainchainId
Ethereum1
Optimism10
Polygon137
Base8453
Arbitrum One42161

Examples

Networks

Loading...
network-logo-networks.tsxShow code
import { NetworkLogo } from "@/components/ui/network-logo"export function NetworkLogoNetworks() {  return (    <div className="flex items-center gap-3">      <NetworkLogo chainId={1} />      <NetworkLogo chainId={8453} />      <NetworkLogo chainId={10} />      <NetworkLogo chainId={42161} />      <NetworkLogo chainId={137} />    </div>  )}

Sizes

Loading...
network-logo-sizes.tsxShow code
import { NetworkLogo } from "@/components/ui/network-logo"export function NetworkLogoSizes() {  return (    <div className="flex items-center gap-3">      <NetworkLogo chainId={8453} size="xs" />      <NetworkLogo chainId={8453} size="sm" />      <NetworkLogo chainId={8453} size="md" />      <NetworkLogo chainId={8453} size="lg" />      <NetworkLogo chainId={8453} size="xl" />    </div>  )}

Unknown networks

The examples show how the size limit affects unknown chain IDs. 5315 fits at md but shows ? at xs and sm. 42220 shows ? at every size.

Loading...
network-logo-unknown.tsxShow code
import { NetworkLogo } from "@/components/ui/network-logo"export function NetworkLogoUnknown() {  return (    <div className="flex items-center gap-3">      <NetworkLogo chainId={5315} size="xs" />      <NetworkLogo chainId={5315} size="sm" />      <NetworkLogo chainId={5315} size="md" />      <NetworkLogo chainId={42220} size="md" />      <NetworkLogo chainId={42220} size="xl" />    </div>  )}

Custom network

Z
network-logo-custom.tsxShow code
import { NetworkLogo } from "@/components/ui/network-logo"export function NetworkLogoCustom() {  return (    <NetworkLogo      name="Zora"      symbol="ZORA"      fallback="Z"      className="border-foreground/20 bg-foreground text-background"      showTooltip    />  )}

Props

PropTypeDefaultDescription
chainIdnumber | null-EVM chain id
srcstring | nullBuilt-in chain logoNetwork image URL override
namestring | nullBuilt-in network nameNetwork name
symbolstring | nullBuilt-in network symbolShort symbol for fallback
size"xs" | "sm" | "md" | "lg" | "xl""md"Visual size
fallbackReactNodeSymbol/name/chain fallbackCustom fallback for unsupported chains
showTooltipbooleanfalseShow an animated tooltip
tooltipContentReactNodeName, symbol, then chain idTooltip content
classNamestring-Applied to the root wrapper
imageClassNamestring-Applied to the image
fallbackClassNamestring-Applied to the fallback

On this page