Overview
A UI element that renders a button for initiating withdrawals. This element provides a convenient one-click withdrawal experience:- Shows current available balance
- Automatically handles verification if required
- Opens withdrawal modal when clicked
- Supports customizable styling
Usage
Basic usage
Customized button
Handling verification
Events
Events emitted by the WithdrawButtonElement. Listen to these events using theon() method or by passing callback functions in the options.
error
Emitted when an error occurs during element initialization or operation.
Callback signature: (error: unknown) => void
ready
Emitted when the element has finished loading and is ready for user interaction.
Callback signature: (element: WithdrawButtonElement) => void
optionsUpdated
Emitted when the element’s options are updated via updateOptions().
Callback signature: (options: WithdrawButtonElementOptions) => void
verify
Emitted when the user clicks the button and needs to verify their identity first.
By default, opens the verification modal. Call ev.preventDefault() to handle this yourself.
Callback signature: (ev: CustomEvent<WithdrawButtonElement>) => void
withdraw
Emitted when the user clicks the button to initiate a withdrawal.
By default, opens the withdrawal modal. Call ev.preventDefault() to handle this yourself.
Callback signature: (ev: CustomEvent<WithdrawButtonElement>) => void
snapshot
Emitted when the element’s internal state changes.
Callback signature: (snapshot: WithdrawButtonElementSnapshot) => void
verificationSubmitted
Emitted when the user successfully submits verification through the modal opened by this button.
Callback signature: (ev: CustomEvent<WithdrawButtonElement>) => void
withdrawalRequested
Emitted when the user successfully requests a withdrawal through the modal opened by this button.
Callback signature: (ev: CustomEvent<WithdrawButtonElement>) => void
Methods
mount(container)
Mount the element to a DOM container.
The container must be an empty element. The element will be appended as a child.
If the element is already mounted, this method will log a warning and return.
| Parameter | Type | Description |
|---|---|---|
container | HTMLElement | #$\{string\} | The container element or a CSS selector starting with ’#‘ |
unmount()
Remove the element from the DOM and clean up all event listeners.
After unmounting, the element instance should not be reused.
Create a new element instance if you need to mount again.
updateOptions(options)
Update the element’s configuration options after creation.
Only the provided options will be updated; other options remain unchanged.
The element will re-render with the new options.
| Parameter | Type | Description |
|---|---|---|
options | Partial<WithdrawButtonElementOptions> | Partial options object with the values to update |
getSnapshot()
Get the current state snapshot of the element.
The snapshot contains the element’s current internal state, such as
loading status, form values, or other element-specific data.
Returns: WithdrawButtonElementSnapshot
Types
WithdrawButtonElementOptions
Configuration options for the WithdrawButtonElement.| Property | Type | Required | Default | Description |
|---|---|---|---|---|
hidePendingBalance | boolean | undefined | No | false | Whether to hide the pending balance from the button display. |
onReady | ((element: WithdrawButtonElement) => void) | undefined | No | - | Callback fired when the element has finished loading and is ready for interaction. This is equivalent to listening to the ‘ready’ event. |
onVerificationSubmitted | ((ev: CustomEvent<WithdrawButtonElement>) => void) | undefined | No | - | Callback fired when the user successfully submits verification through this button’s flow. |
onWithdrawalRequested | ((ev: CustomEvent<WithdrawButtonElement>) => void) | undefined | No | - | Callback fired when the user successfully requests a withdrawal through this button’s flow. |
size | "1" | "2" | "3" | "4" | undefined | No | - | The size of the button. - ‘“1”’ - Extra small - ‘“2”’ - Small - ‘“3”’ - Medium (default) - ‘“4”’ - Large |
variant | "solid" | "soft" | "surface" | "ghost" | "classic" | undefined | No | - | The visual variant of the button. - ‘“solid”’ - Filled background - ‘“soft”’ - Subtle background - ‘“surface”’ - Surface-level emphasis - ‘“ghost”’ - No background - ‘“classic”’ - Traditional button style |
color | AccentColor | undefined | No | - | The accent color for the button. |
highContrast | boolean | undefined | No | false | Whether to use high contrast mode for better accessibility. |
WithdrawButtonElementSnapshot
Represents the current state of the WithdrawButtonElement. Useelement.getSnapshot() to get the current state, or listen to the snapshot event for changes.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
state | "loading" | "ready" | Yes | - | The current loading state of the element. - ‘“loading”’ - The element is initializing - ‘“ready”’ - The element is fully loaded and interactive |

