You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the Pay Modal is integrated with the `TransactionButton` component. If the user performs a transaction and does not have enough funds to execute it and if [thirdweb pay](https://portal.thirdweb.com/connect/pay/buy-with-crypto) is available for that blockchain, the Pay Modal will be displayed to allow user to buy the required amount of tokens
8
+
9
+
A new prop `payModal` is added to the `TransactionButton` component customize the Pay Modal UI or disable it entirely
10
+
11
+
Example: Disable Pay Modal
12
+
13
+
```tsx
14
+
<TransactionButtonpayModal={false}> Example 1 </TransactionButton>
15
+
```
16
+
17
+
Example: Customize Pay Modal UI
18
+
19
+
```tsx
20
+
<TransactionButton
21
+
payModal={{
22
+
theme: "light",
23
+
}}
24
+
>
25
+
Example 2
26
+
</TransactionButton>
27
+
```
28
+
29
+
### Disable Pay Modal for certain configurations in `useSendTransaction` hook
30
+
31
+
If `useSendTransaction` hook is passed `gasless: true` configuration or if current active wallet is a smart wallet with `sponsorGas: true` configuration - the Pay Modal will be disabled
* Configuration for the "Pay Modal" that opens when the user doesn't have enough funds to send a transaction.
24
+
* Set `payModal: false` to disable the "Pay Modal" popup
25
+
*
26
+
* This configuration object includes the following properties to configure the "Pay Modal" UI:
27
+
*
28
+
* ### `locale`
29
+
* The language to use for the "Pay Modal" UI. Defaults to `"en_US"`.
30
+
*
31
+
* ### `supportedTokens`
32
+
* An object of type [`SupportedTokens`](https://portal.thirdweb.com/references/typescript/v5/SupportedTokens) to configure the tokens to show for a chain.
33
+
*
34
+
* ### `theme`
35
+
* The theme to use for the "Pay Modal" UI. Defaults to `"dark"`.
36
+
*
37
+
* It can be set to `"light"` or `"dark"` or an object of type [`Theme`](https://portal.thirdweb.com/references/typescript/v5/Theme) for a custom theme.
38
+
*
39
+
* Refer to [`lightTheme`](https://portal.thirdweb.com/references/typescript/v5/lightTheme)
40
+
* or [`darkTheme`](https://portal.thirdweb.com/references/typescript/v5/darkTheme) helper functions to use the default light or dark theme and customize it.
41
+
*/
42
+
exporttypeSendTransactionPayModalConfig=
43
+
|{
44
+
locale?: LocaleId;
45
+
supportedTokens?: SupportedTokens;
46
+
theme?: Theme|"light"|"dark";
47
+
}
48
+
|false;
49
+
20
50
/**
21
51
* Configuration for the `useSendTransaction` hook.
22
52
*/
@@ -41,14 +71,7 @@ export type SendTransactionConfig = {
41
71
* Refer to [`lightTheme`](https://portal.thirdweb.com/references/typescript/v5/lightTheme)
42
72
* or [`darkTheme`](https://portal.thirdweb.com/references/typescript/v5/darkTheme) helper functions to use the default light or dark theme and customize it.
43
73
*/
44
-
payModal?:
45
-
|{
46
-
locale?: LocaleId;
47
-
supportedTokens?: SupportedTokens;
48
-
theme?: Theme|"light"|"dark";
49
-
}
50
-
|false;
51
-
74
+
payModal?: SendTransactionPayModalConfig;
52
75
/**
53
76
* Configuration for gasless transactions.
54
77
* Refer to [`GaslessOptions`](https://portal.thirdweb.com/references/typescript/v5/GaslessOptions) for more details.
@@ -73,11 +96,31 @@ export type SendTransactionConfig = {
@@ -72,6 +75,28 @@ export type TransactionButtonProps = {
72
75
* The button's disabled state
73
76
*/
74
77
disabled?: boolean;
78
+
79
+
/**
80
+
* Configuration for the "Pay Modal" that opens when the user doesn't have enough funds to send a transaction.
81
+
* Set `payModal: false` to disable the "Pay Modal" popup
82
+
*
83
+
* This configuration object includes the following properties to configure the "Pay Modal" UI:
84
+
*
85
+
* ### `locale`
86
+
* The language to use for the "Pay Modal" UI. Defaults to `"en_US"`.
87
+
*
88
+
* ### `supportedTokens`
89
+
* An object of type [`SupportedTokens`](https://portal.thirdweb.com/references/typescript/v5/SupportedTokens) to configure the tokens to show for a chain.
90
+
*
91
+
* ### `theme`
92
+
* The theme to use for the "Pay Modal" UI. Defaults to `"dark"`.
93
+
*
94
+
* It can be set to `"light"` or `"dark"` or an object of type [`Theme`](https://portal.thirdweb.com/references/typescript/v5/Theme) for a custom theme.
95
+
*
96
+
* Refer to [`lightTheme`](https://portal.thirdweb.com/references/typescript/v5/lightTheme)
97
+
* or [`darkTheme`](https://portal.thirdweb.com/references/typescript/v5/darkTheme) helper functions to use the default light or dark theme and customize it.
98
+
*/
99
+
payModal?: SendTransactionPayModalConfig;
75
100
};
76
101
77
102
/**
@@ -100,6 +125,7 @@ export function TransactionButton(props: TransactionButtonProps) {
100
125
onError,
101
126
onClick,
102
127
gasless,
128
+
payModal,
103
129
disabled,
104
130
...buttonProps
105
131
}=props;
@@ -108,7 +134,10 @@ export function TransactionButton(props: TransactionButtonProps) {
0 commit comments