Display wallet balance with loading states and customizable formatting.
No wallet connected
- Balance
- SOL
Installation
pnpm dlx shadcn@latest add @wallet-kit/balance
Usage
import { WalletBalance } from "@/components/wallet/balance";
export default function Demo() {
return <WalletBalance />;
}API Reference
WalletBalance
Displays the connected wallet's balance. Shows a loading skeleton when no wallet is connected or while fetching balance.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
format | (balance: bigint) => string | - | Custom formatter function for the balance. Receives the balance as bigint. |
showSymbol | boolean | true | Whether to display the currency symbol (e.g., "SOL"). |
symbol | string | "SOL" | The currency symbol to display. |
decimals | number | 9 | Number of decimal places for the balance (default: 9 for Solana). |
className | string | - | Additional CSS classes. |
Inherits all props from div.
Behavior
- No Wallet: Displays a loading skeleton
- With Wallet: Shows the formatted balance with the currency symbol
- Custom Formatting: Use the
formatprop to customize how the balance is displayed
Examples
Basic Usage
import { WalletBalance } from "@/components/wallet/balance";
export default function BalanceDisplay() {
return (
<div className="flex items-center gap-2">
<WalletBalance />
</div>
);
}Custom Formatting
import { WalletBalance } from "@/components/wallet/balance";
export default function CustomBalance() {
return (
<WalletBalance
format={(balance) => {
const sol = Number(balance) / 1e9;
return sol.toLocaleString("en-US", {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
}}
/>
);
}Without Symbol
import { WalletBalance } from "@/components/wallet/balance";
export default function BalanceNoSymbol() {
return <WalletBalance showSymbol={false} />;
}- The component automatically handles loading states with a skeleton
- Default formatting uses 4 decimal places for readability
- The balance is stored as
bigintto handle large numbers accurately - Custom formatters should handle the conversion from
bigintto a displayable string - Currently displays a placeholder balance; implement blockchain-specific balance fetching in your application
Last updated 11/21/2025