By default,Documentation Index
Fetch the complete documentation index at: https://docs.trustware.io/llms.txt
Use this file to discover all available pages before exploring further.
TrustwareWidget manages its own open/closed state. When your app needs to trigger the deposit flow from elsewhere — a button in a nav bar, a checkout step, a game event — you can take control of that state using a ref.
When to use this pattern
Choose this pattern when:- your app needs to open or close the deposit flow from outside the widget
- you want to set the initial step the user lands on
- you need lifecycle callbacks for when the widget opens or closes
Setup
Widget props
| Prop | Type | Description |
|---|---|---|
theme | "light" | "dark" | "system" | Sets the widget color scheme. Defaults to "system". |
initialStep | "home" | "select-token" | "crypto-pay" | "processing" | "success" | "error" | The step the widget opens on. Defaults to "home". |
defaultOpen | boolean | Whether the widget renders open on first mount. |
onOpen | () => void | Callback fired when the widget opens. |
onClose | () => void | Callback fired when the widget closes. |
showThemeToggle | boolean | Whether to show the theme toggle control inside the widget. |
Using the ref
TrustwareWidgetRef exposes three methods:
| Method | Description |
|---|---|
open() | Open the widget. |
close() | Close the widget. Shows a confirmation dialog first if a transaction is in progress. |
isOpen() | Returns true when the widget is currently open. Useful for syncing your own UI state. |
The
?. optional chaining guard is important — ref.current is null until the widget mounts. Using widgetRef.current?.open() prevents a runtime error if the button is clicked before the widget renders.Starting on a specific step
UseinitialStep to land the user at a particular point in the flow rather than the home screen. This is useful when you already know the context — for example, if the user has already selected a token elsewhere in your UI.
