Skip to content

Action Button

Run a server action and report whether it succeeded, was refused or has an unknown result.

View template

The button shows pending while the request runs and ignores further clicks. A 2xx response means succeeded. A 4xx response other than 408 means rejected: the server refused and nothing changed. A 5xx, 408, timeout or network error means unknown: the action may have happened, so check the current state before you retry. The Mero-Action-Outcome header overrides the state and Mero-Action-Message overrides the text. Each step dispatches a bubbling mero:action event, and data-mero-action-state exposes the state for styling.

Use in your app

Copy these tags into your page head once. Serve the files at the paths shown, then add the example’s template to your page.

Page assets
<link rel="stylesheet" href="/mero.css">
<script defer src="/vendor/htmx.min.js"></script>
<script defer src="/mero.js"></script>
<script defer src="/mero-forms.js"></script>

Point the HTMX attributes at your own HTML endpoints. Use the live preview’s HTTP exchange to inspect the request and response.

Download library and examples ↓