Unified Balance
Display the user’s unified token balances across chains with per-token and per-chain breakdown.
MAIN POINTS TO NOTE:
- This widget reads balances from the Nexus context which is populated via
getUnifiedBalances(true)in the provider; it does not perform network calls by itself. - The widget filters out zero balances, groups by token, and shows per-chain breakdown with formatted amounts and approximate fiat.
- To refresh balances after actions, call
fetchUnifiedBalance()from the provider; the widget will re-render with updated context. - You can find a quickstart example for using
nexus-elementsin Nexus Elements Quickstart.
Install
You can find the source code for the Unified Balance Widget here:
To install the Unified Balance Widget into your project, you can use the following command:
pnpm
Terminal
pnpm dlx shadcn@latest add https://elements.nexus.availproject.org/r/unified-balance.jsonProps
TypeScript
interface UnifiedBalanceProps {
className?: string;
}className(optional): Style override for the outer container.
Usage
tsx
"use client";
import UnifiedBalance from "@/components/unified-balance/unified-balance";
function App() {
return <UnifiedBalance />;
}Last updated on