Skip to main content

ConnectModal

Description

ConnectModal is a nicely designed wallet-select modal for wallet selection.

tip

Usually you won't need to import it because we hide it inside our ConnectButton. Unless you want to customize your own ConnectButton along with our connect modal.

Examples

Here is an example for you to use with your own connect button.

import { useWallet, ConnectModal } from '@suiet/wallet-kit';

function App() {
const {connected} = useWallet()
const [showModal, setShowModal] = useState(false)

if (connected) {
return <YourComponent />
}
return (
// wrap your own button as the trigger of the modal
<ConnectModal
open={showModal}
onOpenChange={(open) => setShowModal(open)}
>
<YourOwnButton />
</ConnectModal>;
)
}

API

Props

PropertiesDescriptionTypeDefault
childrentrigger element for the modalReactNodenull
openIndicator for opening the modalbooleanfalse
onOpenChangevisibility change event(open: boolean) => void--
onConnectSuccessCallback for successful connection(walletName: string) => void
onConnectErrorCallback for failed connection(error: BaseError) => void