@@ -4,7 +4,7 @@ description: React hooks for interacting with the Flow blockchain.
4
4
sidebar_position : 1
5
5
---
6
6
7
- import { Connect , TransactionDialog , TransactionLink } from " @onflow/kit"
7
+ import { Connect , TransactionDialog , TransactionLink , TransactionButton } from " @onflow/kit"
8
8
import { FlowProvider } from " @onflow/kit"
9
9
import FlowProviderDemo from ' @site/src/components/FlowProviderDemo' ;
10
10
@@ -206,6 +206,58 @@ import { Connect } from "@onflow/kit"
206
206
207
207
---
208
208
209
+ ### ` TransactionButton `
210
+
211
+ Button component for executing Flow transactions with built-in loading states and global transaction management.
212
+
213
+ ** Props:**
214
+
215
+ - ` transaction: Parameters<typeof mutate>[0] ` – Flow transaction object to execute when clicked
216
+ - ` label?: string ` – Optional custom button label (default: ` "Execute Transaction" ` )
217
+ - ` mutation?: UseMutationOptions<string, Error, Parameters<typeof mutate>[0]> ` – Optional TanStack React Query mutation options
218
+ - ` ...buttonProps ` – All other ` ButtonProps ` except ` onClick ` and ` children ` (includes ` variant ` , ` disabled ` , ` className ` , etc.)
219
+
220
+ ``` tsx
221
+ import { TransactionButton } from " @onflow/kit"
222
+
223
+ const myTransaction = {
224
+ cadence: `
225
+ transaction() {
226
+ prepare(acct: &Account) {
227
+ log("Hello from ", acct.address)
228
+ }
229
+ }
230
+ ` ,
231
+ args : (arg , t ) => [],
232
+ limit: 100 ,
233
+ }
234
+
235
+ <TransactionButton
236
+ transaction = { myTransaction }
237
+ label = " Say Hello"
238
+ variant = " primary"
239
+ mutation = { {
240
+ onSuccess : (txId ) => console .log (" Transaction sent:" , txId ),
241
+ onError : (error ) => console .error (" Transaction failed:" , error ),
242
+ }}
243
+ />
244
+ ```
245
+
246
+ ### Live Demo
247
+
248
+ <FlowProviderDemo >
249
+ <TransactionButton
250
+ transaction = { {
251
+ cadence: ` transaction() { prepare(acct: &Account) { log("Demo transaction") } } ` ,
252
+ args : (arg , t ) => [],
253
+ limit: 100 ,
254
+ }}
255
+ label = " Demo Transaction"
256
+ />
257
+ </FlowProviderDemo >
258
+
259
+ ---
260
+
209
261
### ` TransactionDialog `
210
262
211
263
Dialog component for real-time transaction status updates.
0 commit comments