Rainbow logo
RainbowKit
0.0.2

Custom ConnectButton

Creating a custom ConnectButton

You can use the low-level ConnectButton.Custom to create your own custom connection button. This component renders a function, which includes everything you need to re-implement the built-in buttons.

A minimal re-implementation of the built-in buttons would look something like this:

import { ConnectButton } from '@rainbow-me/rainbowkit';
export const YourApp = () => {
return (
<ConnectButton.Custom>
{({
account,
chain,
openAccountModal,
openChainModal,
openConnectModal,
}) =>
!account ? (
<button onClick={openConnectModal}>Connect Wallet</button>
) : (
<div>
{chain && (
<button onClick={openChainModal}>
{chain.iconUrl && (
<img alt={chain.name ?? 'Chain icon'} src={chain.iconUrl} />
)}
{chain.name ?? chain.id}
{chain.unsupported && ' (unsupported)'}
</button>
)}
<button onClick={openAccountModal}>
{account.displayName}
{account.displayBalance
? ` (${account.displayBalance})`
: ''}
</button>
</div>
)
}
</ConnectButton.Custom>
);
};

The following props are passed to your render function.

Account properties

PropTypeDefault
accountobject | undefined
account.addressstring
account.balanceDecimalsstring | undefined
account.balanceFormattedstring | undefined
account.balanceSymbolstring | undefined
account.displayBalancestring | undefined
account.displayNamestring
account.ensAvatarstring | undefined
account.ensNamestring | undefined

Chain properties

PropTypeDefault
chainobject | undefined
chain.hasIconboolean
chain.iconUrlstring | undefined
chain.iconBackgroundstring | undefined
chain.idnumber
chain.namestring | undefined
chain.unsupportedboolean | undefined

Modal state properties

PropTypeDefault
openAccountModal() => void
openChainModal() => void
openConnectModal() => void
accountModalOpenboolean
chainModalOpenboolean
connectModalOpenboolean