Files
cap/docs/guide/floating.md
T

24 lines
1.1 KiB
Markdown
Raw Normal View History

2025-01-11 18:31:39 +00:00
# Floating mode
Cap can automatically hide the captcha until the form is submitted. To use this feature, add the `data-cap-floating` attribute to the Cap widget with the query selector of the `cap-widget` element you want to use.
```html
2025-01-14 13:30:57 +00:00
<cap-widget id="floating" onsolve="alert(`Verification token: ${event.detail.token}`)" data-cap-api-endpoint="<api endpoint>"></cap-widget>
2025-01-12 13:48:02 +00: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-01-12 13:48:02 +00:00
```html{2}
<script src="https://cdn.jsdelivr.net/npm/@cap.js/widget"></script>
<script src="https://cdn.jsdelivr.net/npm/@cap.js/widget/cap-floating.min.js"></script>
2025-01-12 13:48:02 +00:00
```
> [!NOTE]
> You'll not need to re-import the main Cap library if you've already done it.
2025-01-11 18:31:39 +00:00
The following attributes are supported:
- `data-cap-floating`: The query selector of the `cap-widget` element you want to use.
- `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.