Skip to content

ConnectModal

Description

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

Examples

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

import React, { useState } from 'react';
import { useWallet, ConnectModal } from '@razorlabs/razorkit';
 
const YourComponent: React.FC = () => {
  return <div>Your Own Component</div>
}
 
const YourOwnButton: React.FC = () => {
  return <button>Your Own Button</button>
}
 
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