Skip to content

Commit e7b9b9f

Browse files
authored
add useWalletDetailsModal hook (thirdweb-dev#3229)
1 parent 95c4151 commit e7b9b9f

File tree

10 files changed

+461
-172
lines changed

10 files changed

+461
-172
lines changed

.changeset/three-wombats-tease.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Add `useWalletDetailsModal` hook to open Wallet Details Modal without using `<ConnectButton />` component
6+
7+
```tsx
8+
import { createThirdwebClient } from "thirdweb";
9+
import { useWalletDetailsModal } from "thirdweb/react";
10+
11+
const client = createThirdwebClient({
12+
clientId: "<your_client_id>",
13+
});
14+
15+
function Example() {
16+
const { open } = useWalletDetailsModal();
17+
18+
function handleClick() {
19+
open({ client, theme: "light" });
20+
}
21+
22+
return <button onClick={handleClick}> Show Wallet Details </button>;
23+
}
24+
```

packages/thirdweb/src/exports/react.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,8 @@ export {
135135
useWalletInfo,
136136
useWalletImage,
137137
} from "../react/web/ui/hooks/useWalletInfo.js";
138+
139+
export {
140+
useWalletDetailsModal,
141+
type UseWalletDetailsModalOptions,
142+
} from "../react/web/ui/ConnectWallet/Details.js";

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ function ConnectButtonInner(
294294
chains={props?.chains || []}
295295
chain={props.chain}
296296
switchButton={props.switchButton}
297+
client={props.client}
298+
connectLocale={locale}
297299
/>
298300
);
299301
}

packages/thirdweb/src/react/web/ui/ConnectWallet/ConnectButtonProps.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,6 @@ export type ConnectButton_detailsModalOptions = {
132132
*/
133133
networkSelector?: NetworkSelectorProps;
134134

135-
/**
136-
* Hide the "Switch to Personal wallet" option in the Connect Wallet details modal which is shown when wallet is connected to either Smart Wallet or Safe.
137-
*
138-
* By default it is `false`
139-
* @example
140-
* ```tsx
141-
* <ConnectButton detailsModal={{
142-
* hideSwitchToPersonalWallet: true
143-
* }}
144-
* />
145-
* ```
146-
*/
147-
hideSwitchToPersonalWallet?: boolean;
148-
149135
/**
150136
* Hide the "Disconnect Wallet" button in the `ConnectButton` Details Modal.
151137
*

0 commit comments

Comments
 (0)