File tree 3 files changed +36
-2
lines changed
evm/components/Web3Button
3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @thirdweb-dev/react " : patch
3
+ ---
4
+
5
+ Add prop ` switchNetworkBtnTitle ` to ` ConnectWallet ` and ` Web3Button ` components to allow changing the "Switch Network" label on the button which is displayed when user needs to switch the network in the connected wallet.
6
+
7
+ ``` tsx
8
+ <ConnectWallet switchNetworkBtnTitle = " Switch Chain" />
9
+ ```
10
+
11
+ ``` tsx
12
+ <Web3Button
13
+ switchNetworkBtnTitle = " Switch Chain"
14
+ contractAddress = " 0x..."
15
+ action = { someAction }
16
+ />
17
+ ```
Original file line number Diff line number Diff line change @@ -186,6 +186,11 @@ export interface Web3ButtonProps<TActionFn extends ActionFn> {
186
186
*/
187
187
welcomeScreen ?: WelcomeScreen ;
188
188
} ;
189
+
190
+ /**
191
+ * Set a custom label for the "Switch Network" button
192
+ */
193
+ switchNetworkBtnTitle ?: string ;
189
194
}
190
195
191
196
/**
@@ -255,6 +260,8 @@ export const Web3Button = <TAction extends ActionFn>(
255
260
const theme = props . theme || contextTheme || "dark" ;
256
261
257
262
const locale = useTWLocale ( ) ;
263
+ const switchNetworkLabel =
264
+ props . switchNetworkBtnTitle || locale . connectWallet . switchNetwork ;
258
265
259
266
const [ confirmStatus , setConfirmStatus ] = useState < "idle" | "waiting" > (
260
267
"idle" ,
@@ -337,7 +344,7 @@ export const Web3Button = <TAction extends ActionFn>(
337
344
{ confirmStatus === "waiting" ? (
338
345
< Spinner size = "sm" color = { "primaryButtonText" } />
339
346
) : (
340
- locale . connectWallet . switchNetwork
347
+ switchNetworkLabel
341
348
) }
342
349
</ Button >
343
350
) ;
Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ export type ConnectWalletProps = {
79
79
*/
80
80
btnTitle ?: string ;
81
81
82
+ /**
83
+ * Set a custom label for the "Switch Network" button
84
+ */
85
+ switchNetworkBtnTitle ?: string ;
86
+
82
87
/**
83
88
* Change the title of ConnectWallet Modal
84
89
*
@@ -722,6 +727,7 @@ export function ConnectWallet(props: ConnectWalletProps) {
722
727
< SwitchNetworkButton
723
728
style = { props . style }
724
729
className = { props . className }
730
+ switchNetworkBtnTitle = { props . switchNetworkBtnTitle }
725
731
/>
726
732
) ;
727
733
}
@@ -784,12 +790,16 @@ export function ConnectWallet(props: ConnectWalletProps) {
784
790
function SwitchNetworkButton ( props : {
785
791
style ?: React . CSSProperties ;
786
792
className ?: string ;
793
+ switchNetworkBtnTitle ?: string ;
787
794
} ) {
788
795
const { activeChain } = useWalletContext ( ) ;
789
796
const switchChain = useSwitchChain ( ) ;
790
797
const [ switching , setSwitching ] = useState ( false ) ;
791
798
const locale = useTWLocale ( ) ;
792
799
800
+ const switchNetworkBtnTitle =
801
+ props . switchNetworkBtnTitle ?? locale . connectWallet . switchNetwork ;
802
+
793
803
return (
794
804
< AnimatedButton
795
805
className = { `${ TW_CONNECT_WALLET } --switch-network ${
@@ -818,7 +828,7 @@ function SwitchNetworkButton(props: {
818
828
{ switching ? (
819
829
< Spinner size = "sm" color = "primaryButtonText" />
820
830
) : (
821
- locale . connectWallet . switchNetwork
831
+ switchNetworkBtnTitle
822
832
) }
823
833
</ AnimatedButton >
824
834
) ;
You can’t perform that action at this time.
0 commit comments