2025-01-11 18:31:39 +00:00
# Floating mode
2025-04-12 13:39:56 +01:00
Cap can automatically hide the CAPTCHA until a button is pressed. To use this, add the `data-cap-floating` attribute to the Cap widget with the query selector of the `cap-widget` element you want to use.
2025-01-11 18:31:39 +00:00
```html
2025-04-12 13:39:56 +01:00
< cap-widget
id = "floating"
onsolve = "console.log(`token: ${event.detail.token}`)"
data-cap-api-endpoint = "<api endpoint>"
></ cap-widget >
2025-01-12 13:48:02 +00:00
2025-04-12 13:39:56 +01:00
< button data-cap-floating = "#floating" data-cap-floating-position = "bottom" >
Trigger floating mode
</ button >
2025-01-11 18:31:39 +00:00
```
You'll also need to import both the Cap library and the floating mode script from JSDelivr:
2025-04-12 13:39:56 +01:00
2025-01-12 13:48:02 +00:00
```html{2}
2025-01-13 20:01:26 +00:00
<script src="https://cdn.jsdelivr.net/npm/@cap.js/widget"></script>
2025-04-12 13:39:56 +01:00
<script src="https://cdn.jsdelivr.net/npm/@cap.js/widget/cap-floating.min.js"></script> <!-- [!code ++] -->
2025-01-12 13:48:02 +00:00
` ``
2025-05-10 10:34:44 +01:00
Or from the standalone server:
` ``html
<script src="https://<server url>/assets/widget.js"></script>
<script src="https://<server url>/assets/floating.js"></script> <!-- [!code ++] -->
` ``
2025-01-11 18:31:39 +00:00
The following attributes are supported:
2025-04-12 13:39:56 +01:00
- ` data-cap-floating`: The CSS selector of the ` cap-widget` element you want to use.
2025-01-11 18:31:39 +00:00
- ` data-cap-floating-position`: The position of the floating widget. Can be ` top` or ` bottom`.
- ` data-cap-floating-offset`: The offset of the floating widget from the trigger element.