Skip to content

Commit 8ae8e6a

Browse files
Cleanup TransactionButton loading state (#2870)
Co-authored-by: Manan Tank <manantankm@gmail.com>
1 parent d2aead4 commit 8ae8e6a

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.changeset/unlucky-experts-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix TransactionButton layout shift while loading

packages/thirdweb/src/react/web/ui/TransactionButton/index.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export function TransactionButton(props: TransactionButtonProps) {
111111
return (
112112
<Button
113113
gap="xs"
114-
{...buttonProps}
115114
disabled={!account || disabled}
116115
variant={"primary"}
117116
data-is-loading={isPending}
@@ -146,9 +145,11 @@ export function TransactionButton(props: TransactionButtonProps) {
146145
}
147146
}}
148147
style={{
149-
...buttonProps.style,
150148
opacity: !account || disabled ? 0.5 : 1,
149+
minWidth: "150px",
150+
...buttonProps.style,
151151
}}
152+
{...buttonProps}
152153
>
153154
{children}
154155
</Button>
@@ -157,15 +158,29 @@ export function TransactionButton(props: TransactionButtonProps) {
157158

158159
return (
159160
<Button
160-
{...buttonProps}
161161
disabled={true}
162162
variant={"primary"}
163163
style={{
164-
...buttonProps.style,
164+
opacity: !account || disabled ? 0.5 : 1,
165165
minWidth: "150px",
166+
position: "relative",
167+
...buttonProps.style,
166168
}}
169+
{...buttonProps}
167170
>
168-
<Spinner size="md" color="primaryButtonText" />
171+
<div
172+
style={{
173+
position: "absolute",
174+
display: "flex",
175+
alignItems: "center",
176+
height: "100%",
177+
top: 0,
178+
bottom: 0,
179+
margin: "auto",
180+
}}
181+
>
182+
<Spinner size="md" color="primaryButtonText" />
183+
</div>
169184
</Button>
170185
);
171186
}

0 commit comments

Comments
 (0)