Skip to content

Commit fcc7360

Browse files
authored
Add TransactionButton docs (#1335)
1 parent 3d53fe1 commit fcc7360

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

docs/tools/kit/index.mdx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: React hooks for interacting with the Flow blockchain.
44
sidebar_position: 1
55
---
66

7-
import { Connect, TransactionDialog, TransactionLink } from "@onflow/kit"
7+
import { Connect, TransactionDialog, TransactionLink, TransactionButton } from "@onflow/kit"
88
import { FlowProvider } from "@onflow/kit"
99
import FlowProviderDemo from '@site/src/components/FlowProviderDemo';
1010

@@ -206,6 +206,58 @@ import { Connect } from "@onflow/kit"
206206

207207
---
208208

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+
209261
### `TransactionDialog`
210262

211263
Dialog component for real-time transaction status updates.

0 commit comments

Comments
 (0)