Introducing a new way to review your PRs.

Read the announcement

solana-foundation / solana-web3.js

Solana JavaScript SDK

View on GitHub

23 documents · Updated Nov 16, 2026

docs / wallet-ui-components

Wallet UI components

The wallet adapter UI gives React applications ready-to-use controls for wallet selection, connection, disconnection, and account actions. These controls share state with WalletProvider, while WalletModalProvider supplies the selection dialog and the UI hooks let an application build its own design. For the wider wallet model, see Wallet adapter integration and Wallet provider and controller lifecycle.

UI role

The UI layer turns wallet state into user actions without becoming a second wallet state store. Buttons and the modal read the current wallet snapshot, call its selection or connection actions, and show the result through labels, icons, and status messages.

The public UI surface includes:

  • Ready-made connection, disconnection, selection, and combined account controls.
  • A modal provider and modal for choosing a discovered wallet.
  • Hooks for custom controls that need wallet state and actions without the default layout.
  • Shared button, wallet icon, and empty-wallet artwork components.
  • CSS classes for the default button, dropdown, modal, focus, hover, and disabled states.

Wallet selection flow

WalletModalProvider owns whether the wallet picker is visible. It places the modal beside its children and exposes useWalletModal() so a button or custom picker can open or close the same dialog. Wallet choice and connection remain the responsibility of the wallet context.

The provider must wrap controls that use the modal hook. It also accepts modal display options such as a custom class name and the portal target.

References: packages/…/WalletModalProvider.tsx• L7-35

Wallet picker

WalletModal presents the wallets currently available from WalletProvider. Selecting a wallet updates the selected wallet and starts its connection request. A successful request closes the picker, while a real failure stays visible as an alert so the user can try again.

The picker uses a native dialog and renders into the configured document container. It supports close and cancel actions, closes when the backdrop is clicked, locks page scrolling while open, and reports an in-progress connection through a status message. If no wallet is available, it shows an empty-wallet state instead of a wallet list.

The selection path is:

flowchart TD
    A[User activates wallet control] --> B{Connected account?}
    B -->|No| C[Open wallet picker]
    B -->|Yes| D[Open account actions]
    C --> E[Show discovered wallets]
    E --> F[User chooses wallet]
    F --> G[Select wallet and request connection]
    G --> H{Connection result}
    H -->|Success| I[Close picker and show account]
    H -->|Failure| J[Keep picker open and show alert]
    D --> K[Copy address, change wallet, or disconnect]

References: packages/…/WalletModal.tsx• L14-135

Multi-action control

WalletMultiButton is the standard single entry point for wallet selection and account actions. Before connection it opens the picker or connects an already selected wallet. After connection it shows a shortened public address and opens actions to copy the address, change the wallet, or disconnect.

The control disables action changes while connection work is pending. It closes its menu when the account disappears and returns focus to the trigger when the menu closes. Applications can use BaseWalletMultiButton when they need custom labels or button content.

References: packages/…/WalletMultiButton.tsx• L18-177

Connection controls

Connection buttons

WalletConnectButton and WalletDisconnectButton expose focused controls for applications that do not need the combined flow. They derive their label, disabled state, wallet name, and wallet icon from the current wallet state, then run the matching wallet action when clicked.

The BaseWalletConnectButton and BaseWalletDisconnectButton variants accept state-specific labels. This lets an application keep the shared action rules while changing its wording, styling, or button content.

References: packages/…/WalletConnectionButton.tsx• L10-125

WalletModalButton is a small control that only toggles the shared picker. It is useful when the application wants a separate connection or account layout but still wants the standard wallet list. A prevented click does not change modal visibility.

References: packages/…/WalletConnectionButton.tsx• L127-145

UI action hooks

Connection and disconnection hooks

useWalletConnectButton() and useWalletDisconnectButton() provide the state and action contract behind the focused buttons. Each hook maps wallet context into a small view model with a button state, disabled flag, optional action, wallet name, and wallet icon.

The connection hook distinguishes a pending connection, an already connected account, a selected wallet that is ready to connect, and the absence of a wallet. The disconnection hook exposes the disconnect action only while an account is connected. This keeps custom controls from calling an action that is not valid for the current state.

References: packages/…/useWalletButton.ts• L4-40

Multi-action hook

useWalletMultiButton() supplies the state needed for an application-owned combined control. It exposes connection and disconnection actions when valid, the public key for account display, wallet identity data, and a callback that passes the current wallet list plus the selection action to a custom picker.

The hook keeps the custom picker on the same wallet action path as the built-in modal. A custom design can therefore replace the presentation without changing how selection, connection, and account state work.

References: packages/…/useWalletButton.ts• L43-84

Icons and artwork

Wallet icons

WalletIcon renders the icon advertised by a wallet and gives it accessible alternative text based on the wallet name. It accepts normal image properties, so applications can adjust the image without changing wallet state behavior. When no wallet exists, it renders no image.

Buttons use the selected or connected wallet icon when one is available. The modal uses WalletIcon for each wallet choice, which gives the picker a consistent identity cue across wallet providers.

References: packages/…/WalletIcon.tsx• L5-19 packages/…/WalletModal.tsx• L112-123

Empty-wallet artwork

WalletSVG provides the visual state for a picker with no discovered wallet. It does not select or connect a wallet. The modal uses it to make the empty state distinct from a failed connection.

References: packages/…/WalletSVG.tsx• L3-91 packages/…/WalletModal.tsx• L112-129

Styling system

Shared button styles

packages/…/styles.css defines the default visual language for the UI controls. The wallet-adapter-button class supplies the base button layout, while trigger, hover, disabled, icon, dropdown, and modal classes refine each control state.

Applications can import these styles for the default appearance or use the class names as a stable styling boundary for a custom theme. The button API also accepts a custom class name and start or end icons.

References: packages/…/styles.css• L1-56 packages/…/Button.tsx• L3-27

The stylesheet separates the account dropdown from the full-screen picker. The dropdown is positioned beside its trigger, while the modal centers a bounded panel over a dimmed page backdrop and adjusts its margins for small screens. Focus-visible rules cover the main button, dropdown actions, and close control.

References: packages/…/styles.css• L58-225 packages/…/WalletMultiButton.tsx• L69-158 packages/…/WalletModal.tsx• L75-134

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the modal provider above every control that calls useWalletModal() or uses a built-in modal-backed button.
  • Keep custom button state labels aligned with the state values returned by the corresponding action hook.
  • Preserve the distinction between selecting a wallet and connecting an account. The picker must not treat a pending selection as a connected account.
  • Keep the modal's portal target, dialog close behavior, and page scroll behavior aligned when changing its container or layout.
  • Keep wallet icon alternative text and status or alert roles intact when changing the button or picker markup.
  • Keep custom themes aligned with the shared class names used by buttons, dropdowns, modal states, and focus states.

Important failure modes

TriggerConsequenceGuard
A modal-backed control renders outside WalletModalProvideruseWalletModal() throws a wallet configuration errorPlace the modal provider above the control tree.
A custom control calls connect while no wallet is selectedThe control has no valid connection actionUse the hook's state and disabled flag before enabling the action.
A connection request is superseded by a newer wallet choiceA late rejection can show a false error or close the wrong pickerKeep request results tied to the current wallet choice.
The wallet list changes while the picker is openA stale choice may no longer be availableUse the current wallet list supplied by the wallet context.
The default stylesheet is not loadedControls remain usable but lose layout, focus, modal, and disabled-state stylingImport packages/…/styles.css or provide equivalent styles for its classes.

Key files

FileWhy to read it
packages/…/index.tsShows the UI components, hooks, and modal types exported to applications.
packages/…/WalletMultiButton.tsxShows the standard path from wallet selection to account actions.
packages/…/WalletModal.tsxShows the wallet picker, connection feedback, close behavior, and empty state.
packages/…/WalletModalProvider.tsxDefines shared modal visibility and the provider boundary for modal controls.
packages/…/WalletConnectionButton.tsxShows focused connect, disconnect, and modal button variants.
packages/…/useWalletButton.tsDefines the headless state and action contract for custom controls.
packages/…/Button.tsxDefines the shared button props and icon slots.
packages/…/WalletIcon.tsxDefines wallet identity image rendering and alternative text.
packages/…/styles.cssDefines the default visual states and layout for the wallet controls.