Components
Token Amount
Formats bigint token amounts without losing precision.
Formats a raw bigint amount for display. Precision is never lost to floating point, and amounts always round toward zero, so a balance never looks larger than it is. Hover to see the exact amount.
1,234.5678USDC
Installation
Section titled “Installation”npx shadcn@latest add @0xui/token-amountpnpm dlx shadcn@latest add @0xui/token-amountyarn dlx shadcn@latest add @0xui/token-amountbunx --bun shadcn@latest add @0xui/token-amountimport { TokenAmount } from "@/components/token-amount";
<TokenAmount value={balance} decimals={6} symbol="USDC" />;Examples
Section titled “Examples”With fiat value
Section titled “With fiat value”0xui doesn’t fetch prices. Pass your own.
2.5ETH$7,876.05
<TokenAmount value={balance} decimals={18} symbol="ETH" price={ethPrice} />Compact
Section titled “Compact”12.5MARB
<TokenAmount value={supply} decimals={18} symbol="ARB" compact />Non-zero amounts too small to show render as a bound instead of a misleading 0.
<0.0001ETH
| Prop | Type | Default | Description |
|---|---|---|---|
value |
bigint |
— | Amount in the token’s smallest unit. |
decimals |
number |
— | Token decimals. |
symbol |
string |
— | Shown after the amount. |
maxDecimals |
number |
4 |
Maximum fraction digits. |
compact |
boolean |
false |
Compact notation, e.g. 1.2M. |
price |
number |
— | Price of one token. Adds a fiat line. |
currency |
string |
"USD" |
ISO 4217 currency for the fiat value. |
locale |
string |
runtime locale | Number formatting locale. |
animate |
boolean |
false |
Morph the amount and fiat value when they change, with Morph Text. Leave off in long lists. |
