HEEx components for the PhoenixCap assets and widget.
Add <PhoenixCap.Components.assets /> to your root layout and render
<PhoenixCap.Components.widget id="signup-captcha" /> in your form.
Summary
Functions
Loads the widget and theme from the endpoint. Render once in the root layout.
Renders a widget with a stable DOM ID. An enclosing form automatically
submits the hidden cap-token field. To position the widget elsewhere,
set form to the target form's ID.
Functions
@spec assets(map()) :: Phoenix.LiveView.Rendered.t()
Loads the widget and theme from the endpoint. Render once in the root layout.
<PhoenixCap.Components.assets />For a custom mount, pass the same public path to both components.
Attributes
endpoint(:string) - Public path where PhoenixCap is mounted. Defaults to"/cap".nonce(:string) - Optional CSP nonce for the widget script. Defaults tonil.
@spec widget(map()) :: Phoenix.LiveView.Rendered.t()
Renders a widget with a stable DOM ID. An enclosing form automatically
submits the hidden cap-token field. To position the widget elsewhere,
set form to the target form's ID.
<PhoenixCap.Components.widget id="signup-check" form="signup" />A standalone widget emits a solve event with the token in
event.detail.token. See the JavaScript guide.
Attributes
id(:string) (required) - Stable DOM ID of the widget.endpoint(:string) - Public path where PhoenixCap is mounted. Defaults to"/cap".form(:string) - DOM ID of the form to associate with the widget. Defaults tonil.required(:boolean) - Require a solved widget before submitting its form. Defaults totrue.- Global attributes are accepted.