# Connect Wallet

> Wallet picker with recent and installed badges, per-wallet pending state and cancel handling.

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

A "Connect wallet" button that opens a wallet picker. The wallets are the connectors in your wagmi config. Browser extensions that announce themselves ([EIP-6963](https://eips.ethereum.org/EIPS/eip-6963)) appear automatically with their own icon.

Pick **Demo Wallet** to try it without an extension.

## Installation

```bash
npx shadcn@latest add @0xui/connect-wallet
```

## Usage

```tsx
import { ConnectWallet } from "@/components/connect-wallet";

<ConnectWallet />;
```

Most apps want [Wallet Button](https://0xui.io/components/wallet-button.md), which shows this button while disconnected and the account once connected.

## Examples

### Custom trigger

`ConnectWallet` accepts every shadcn `Button` prop. Its children become the label.

```tsx
<ConnectWallet variant="outline" title="Sign in with your wallet">
  Sign in
</ConnectWallet>
```

### Your own trigger

Open the picker from anywhere with `ConnectWalletDialog`:

```tsx
import { ConnectWalletDialog } from "@/components/connect-wallet";

const [open, setOpen] = useState(false);

<ConnectWalletDialog open={open} onOpenChange={setOpen} />;
```

### Headless

```tsx
import { useConnectWallet } from "@/components/connect-wallet";

const { wallets, connect, phase, pendingId } = useConnectWallet();
// wallets: { id, name, icon, installed, recent, connector }[]
```

## Behavior

- **Order:** the wallet used last comes first, then installed extensions, then everything else.
- **Fewer choices:** shows `maxVisible` wallets (4 by default). The rest sit behind "Other wallets".
- **Duplicates:** the generic `injected()` connector is hidden when extensions announce themselves, since it would duplicate one of them.
- **Closing:** the dialog closes itself after a successful connection.
- **Small screens:** below 640px the picker opens as a bottom drawer, within thumb reach, and can be swiped away. Set `mode` to force a dialog or a drawer. See [Responsive Dialog](https://0xui.io/components/responsive-dialog.md).

## States

`data-phase` on the dialog holds the current state.

| `data-phase` | What the user sees |
| --- | --- |
| `idle` | Wallet list. |
| `connecting` | Spinner on the chosen wallet, other rows disabled, "Confirm the connection in &lt;wallet&gt;". |
| `cancelled` | The user closed the wallet prompt. Muted "Request cancelled" note. Not an error. |
| `error` | The wallet's message, with `role="alert"`. |

## Props

`ConnectWallet` also accepts all shadcn `Button` props.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` / `defaultOpen` / `onOpenChange` | — | — | Control the dialog. |
| `onConnect` | `(connector: Connector) => void` | — | Called after a wallet connects. |
| `title` | `ReactNode` | `"Connect a wallet"` | Dialog title. |
| `maxVisible` | `number` | `4` | Wallets shown before "Other wallets". |
| `footer` | `ReactNode` | privacy note | Small print under the list. `null` hides it. |
| `mode` | `"auto" \| "dialog" \| "drawer"` | `"auto"` | Bottom drawer on small screens, dialog otherwise. Or force one. |
