onchain-ui
Components

Asset row

Display a token's logo, network, amount, fiat value, and percentage change in one row.

AssetRow shows a holding's token details on the left and its amount and fiat value on the right. Use one row per holding in a portfolio or watchlist.

Loading...
asset-row.tsxShow code
import { AssetRow } from "@/components/ui/asset-row"export function AssetRowDemo() {  return (    <AssetRow      symbol="USDC"      name="USD Coin"      amount={1842.2}      value={1842.2}      change={0.01}      chainId={8453}      subtitle="Base"    />  )}

Installation

npx shadcn add @onchain-ui/asset-row
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 { AssetRow } from "@/components/ui/asset-row"

<AssetRow
  symbol="USDC"
  name="USD Coin"
  amount={1842.2}
  value={1842.2}
  change={0.01}
  chainId={8453}
  subtitle="Base"
/>

AssetRow uses TokenLogo, NetworkLogo, and TokenPrice. Customize them through logoProps, networkLogoProps, and priceProps. Use identityClassName and valueClassName to style the two sides of the row.

Examples

Portfolio

Loading...
asset-row-portfolio.tsxShow code
import { AssetRow } from "@/components/ui/asset-row"export function AssetRowPortfolio({ assets }) {  return (    <div className="grid gap-2">      {assets.map((asset) => (        <AssetRow key={asset.symbol} {...asset} />      ))}    </div>  )}

Watchlist

Hide the amount to use the same row shape for market and watchlist views.

Loading...
asset-row-watchlist.tsxShow code
import { AssetRow } from "@/components/ui/asset-row"export function AssetRowWatchlist({ assets }) {  return (    <div className="grid gap-2">      {assets.map((asset) => (        <AssetRow          key={asset.symbol}          {...asset}          hideAmount          priceProps={{ showChangeIcon: false }}        />      ))}    </div>  )}

Props

PropTypeDefaultDescription
symbolstring-Token symbol
namestring | null-Token name
srcstring | null-Token image URL
addressstring | null-Token contract address, used for icon inference and as a fallback label
isNativebooleanfalseUse the chain's native-currency icon instead of treating address as a token contract
amountnumber | string | null | undefined-Token amount held by the user
valueTokenPriceProps["value"]-Fiat value for the position
changenumber | null-Price or position change percentage
chainIdnumber | null-Network chain id for the logo badge
networkNamestring | null-Network name for the logo badge
networkSrcstring | null-Network image URL for the logo badge
subtitleReactNode-Secondary metadata shown beside the token name
hideAmountbooleanfalseHide the right-side token amount
localestringBrowser/default localeLocale passed to Intl.NumberFormat
maximumFractionDigitsnumber4Maximum fraction digits for token amount
logoPropsPartial<TokenLogoProps>-Props passed to TokenLogo
networkLogoPropsPartial<NetworkLogoProps>-Props passed to NetworkLogo
pricePropsPartial<TokenPriceProps>-Props passed to TokenPrice
classNamestring-Applied to the root wrapper
identityClassNamestring-Applied to the token identity block
valueClassNamestring-Applied to the right-side value block

On this page