</> htmx
🚧 htmx 4.0 is under construction. Read changes →

hx-disable

The hx-disable attribute allows you to specify elements that will have the disabled attribute added to them for the duration of the request. The value of this attribute can be:

Here is an example with a button that will disable itself during a request:

<button hx-post="/example" hx-disable="this">
    Post It!
</button>

When a request is in flight, this will cause the button to be marked with the disabled attribute, which will prevent further clicks from occurring.

The hx-disable attribute also supports specifying multiple CSS selectors separated by commas to disable multiple elements during the request. Here is an example that disables buttons and text input fields of a particular form during the request:

<form hx-post="/example" hx-disable="find input[type='text'], find button">
    <input type="text" placeholder="Type here...">
    <button type="submit">Send</button>
</form>

Note that you can also use the append modifier to add disabled elements CSS selectors to inherited values:

<main hx-disable:inherited="#logout-button">
    ...
  <form hx-post="/example" hx-disable:append="find input[type='text'], find button">
    <input type="text" placeholder="Type here...">
    <button type="submit">Send</button>
  </form>
</main>