# Account

> Connected-account button with a panel for balance, copy, explorer link, account switching and disconnect.

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

The button shows the connected account's avatar and ENS name, or its truncated address. It opens a panel with the balance, current network, copy, explorer link and disconnect. It renders nothing while disconnected.

## Installation

```bash
npx shadcn@latest add @0xui/account
```

## Usage

```tsx
import { Account } from "@/components/account";

<Account />;
```

To show "Connect wallet" while disconnected as well, use [Wallet Button](https://0xui.io/components/wallet-button.md).

## Examples

### Balance in the trigger

```tsx
<Account showBalance />
```

### Switch account

wagmi can hold several wallet connections at once. When more than one wallet is connected, the panel lists the others under "Switch account". Picking one makes it the current account for the whole app. Disconnect only disconnects the current wallet.

There is nothing to configure: the list appears once a second wallet connects, for example through [Connect Wallet](https://0xui.io/components/connect-wallet.md).

Accounts inside one wallet are switched in the wallet itself. wagmi follows the change, and the button updates.

### Extra panel content

Children render at the bottom of the panel, above disconnect:

```tsx
<Account>
  <a href="/settings">Settings</a>
</Account>
```

### Headless

```tsx
import { useConnectedAccount } from "@/components/account";

const { address, ensName, displayName, chain, connector, disconnect } =
  useConnectedAccount();

// With several wallets connected:
const { otherAccounts, switchAccount, isSwitching } = useConnectedAccount();
otherAccounts.map(({ address, connector }) => switchAccount(connector));
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` / `defaultOpen` / `onOpenChange` | — | — | Control the panel. |
| `showBalance` | `boolean` | `false` | Show the native balance in the trigger. |
| `onDisconnect` | `() => void` | — | Called after disconnecting. |
| `children` | `ReactNode` | — | Extra panel content. |
