Skip to content

Components

Token Input

The swap panel. Amount, token picker, fiat value, balance with Max, insufficient-balance state.

Amount Input and Token Select combined into the panel every swap and send form uses. It reads the connected account’s balance of the chosen token, offers Max, and flags amounts above the balance.

Tokens use the token list standard. The demo uses Uniswap’s default list, loaded live with useTokenList.

Terminal window
npx shadcn@latest add @0xui/token-input
import { TokenInput } from "@/components/token-input";
<TokenInput
label="You pay"
value={value}
onValueChange={(next, { amount, insufficient }) => setValue(next)}
token={token}
onTokenChange={setToken}
tokens={tokens}
price={prices[token.symbol]}
/>;

Use insufficient to block the action, and name the reason on the button:

<TransactionButton disabledReason={insufficient ? `Insufficient ${token.symbol}` : undefined} …>
<TokenInput label="You receive" value={quote} onValueChange={() => {}} token={out} readOnly checkBalance={false} />
Prop Type Default Description
label ReactNode — Label above the panel.
value string — Decimal string.
onValueChange (value, { amount, insufficient, balance }) => void — Called on change.
token Token — Selected token.
onTokenChange / tokens — — Pass both to make the token pickable.
popular string[] — Quick picks in the picker.
price / currency number / string — / "USD" Fiat line.
prices Record<symbol, number> — Fiat line for any selected token, and value-sorted holdings in the picker.
checkBalance boolean true Read the balance, offer Max, flag insufficient amounts.
readOnly boolean false For quoted outputs.