1

While using the @solana/wallet-adapter-react-ui package, I noticed that if you children to WalletMultiButton, like so:

<WalletMultiButton>Click me!</WalletMultiButton>

that, once you connect your wallet, the "Click me!" text will overwrite the account address that is displayed.

I opened this github issue (along with a PR) to see if there was a way to display your own unique button text without overwriting the account address.

Or even better, is there a way to add button text and an account address, which you can manage the CSS of, with the current implementation of WalletMultiButton?

1 Answer 1

2

If you want your own custom text AFAIK the only way doing it is by fetching the account address from the useWallet context

const { publicKey } = useWallet();

and change

<WalletMultiButton>Click me!</WalletMultiButton>

to

<WalletMultiButton>Click me! {publicKey?.toBase58()}</WalletMultiButton>

And to manage the CSS you will have to create a wallet_style.css file where you overwite the style of the WalletMultiButton.

2
  • thanks for your reply. I thought of doing this, but it seems redundant since the source of the component already returns a spliced account address: see line 20 github.com/solana-labs/wallet-adapter/blob/master/packages/ui/…
    – platocrat
    Commented Jul 24, 2022 at 12:23
  • ig react-ui is supposed to be simple and we're left to customize it on our own -- hence the use of children. i'll settle on this answer for now and close my issue and PR, thanks again
    – platocrat
    Commented Jul 24, 2022 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.