Skip to content

Add TransactionButton docs #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: feature/playground
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/tools/kit/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,58 @@ import { Connect } from "@onflow/kit"

---

### `TransactionButton`

Button component for executing Flow transactions with built-in loading states and global transaction management.

**Props:**

- `transaction: Parameters<typeof mutate>[0]` – Flow transaction object to execute when clicked
- `label?: string` – Optional custom button label (default: `"Execute Transaction"`)
- `mutation?: UseMutationOptions<string, Error, Parameters<typeof mutate>[0]>` – Optional TanStack React Query mutation options
- `...buttonProps` – All other `ButtonProps` except `onClick` and `children` (includes `variant`, `disabled`, `className`, etc.)

```tsx
import { TransactionButton } from "@onflow/kit"

const myTransaction = {
cadence: `
transaction() {
prepare(acct: &Account) {
log("Hello from ", acct.address)
}
}
`,
args: (arg, t) => [],
limit: 100,
}

<TransactionButton
transaction={myTransaction}
label="Say Hello"
variant="primary"
mutation={{
onSuccess: (txId) => console.log("Transaction sent:", txId),
onError: (error) => console.error("Transaction failed:", error),
}}
/>
```

### Live Demo

<FlowProviderDemo>
<TransactionButton
transaction={{
cadence: `transaction() { prepare(acct: &Account) { log("Demo transaction") } }`,
args: (arg, t) => [],
limit: 100,
}}
label="Demo Transaction"
/>
</FlowProviderDemo>

---

### `TransactionDialog`

Dialog component for real-time transaction status updates.
Expand Down