# Token Input

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

- Install: `npx shadcn@latest add @0xui/token-input`
- Registry JSON: https://0xui.io/r/token-input.json
- Source: https://github.com/fimbul-lab/0xui/blob/main/registry/default/components/token-input.tsx

[Amount Input](https://0xui.io/components/amount-input.md) and [Token Select](https://0xui.io/components/token-select.md) 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](https://0xui.io/getting-started/token-lists.md). The demo uses Uniswap's default list, loaded live with `useTokenList`.

## Installation

```bash
npx shadcn@latest add @0xui/token-input
```

## Usage

```tsx
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:

```tsx
<TransactionButton disabledReason={insufficient ? `Insufficient ${token.symbol}` : undefined} …>
```

### "You receive" panel

```tsx
<TokenInput label="You receive" value={quote} onValueChange={() => {}} token={out} readOnly checkBalance={false} />
```

## Props

| 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. |
