Htmx logo

Htmx

Community
mintarasss
htmx

Expert guidance for building web applications with htmx — the library that gives HTML superpowers by extending it with attributes for AJAX, CSS transitions, WebSockets, and Server-Sent Events. Use this skill whenever the user is working with htmx attributes (hx-get, hx-post, hx-swap, hx-trigger, hx-target, etc.), building hypermedia-driven applications, writing server endpoints that return HTML fragments, implementing patterns like click-to-edit, infinite scroll, active search, lazy loading, inline validation, or any UI pattern that uses HTML-over-the-wire instead of JSON APIs. Also use this skill when the user mentions htmx by name, asks about AJAX without JavaScript frameworks, wants to add interactivity to server-rendered HTML, or is working with any hx-* attributes. Trigger even for partial mentions like 'how do I make this form submit without page reload' or 'load content dynamically' in projects that use htmx.

Overview

Publishermintarasss
Repositoryhtmx-skill
Skill namehtmx
Stars
47
Forks
2
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by mintarasss on GitHub. Read the source before you install it.

Installation

Install the Htmx AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/mintarasss/htmx-skill/tree/main/htmx
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mintarasss/htmx-skill.git /tmp/htmx-skill
mkdir -p .claude/skills
cp -r /tmp/htmx-skill/htmx .claude/skills/htmx
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Htmx in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Htmx on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Htmx is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

htmx Development Guide

htmx gives you access to AJAX, CSS Transitions, WebSockets, and Server-Sent Events directly in HTML using attributes. The core idea: any element can issue HTTP requests, and the response is HTML that gets swapped into the DOM.

The Mental Model

In traditional web apps, only <a> and <form> can make HTTP requests, only click and submit trigger them, and only the full page gets replaced. htmx removes these constraints:

  • Any element can issue a request (<button>, <div>, <span>, <tr>, etc.)
  • Any event can trigger it (click, input, revealed, load, custom events, polling)
  • Any HTTP verb works (GET, POST, PUT, PATCH, DELETE)
  • Any part of the page can be the swap target

The server returns HTML fragments, not JSON. This is the fundamental architectural difference from SPA frameworks.

Core Attributes

HTTP Verbs

AttributeDescription
hx-getIssues a GET request
hx-postIssues a POST request
hx-putIssues a PUT request
hx-patchIssues a PATCH request
hx-deleteIssues a DELETE request

None of the HTTP verb attributes are inherited. An empty value (e.g., hx-get="") requests the current URL.

Example — a button that loads content:

html
<button hx-get="/api/data" hx-target="#result" hx-swap="innerHTML">
  Load Data
</button>
<div id="result"></div>

hx-trigger — What Causes the Request

Controls which event fires the request. Default triggers: click for most elements, change for inputs/selects/textareas, submit for forms.

Syntax: hx-trigger="<event>[<filter>] <modifiers>"

Modifiers:

  • once — trigger only once
  • changed — only if the element's value changed
  • delay:<time> — debounce (e.g., delay:500ms)
  • throttle:<time> — throttle (e.g., throttle:1s)
  • from:<selector> — listen on a different element (supports document, window, closest <sel>, find <sel>, next, previous)
  • target:<selector> — only if the event target matches
  • consume — stop event propagation
  • queue:<first|last|all|none> — queuing strategy

Event filters use JavaScript expressions in brackets:

html
<input hx-get="/search" hx-trigger="keyup[key=='Enter']"/>
<button hx-get="/action" hx-trigger="click[ctrlKey]">Ctrl+Click</button>

Special triggers:

  • load — fires when element loads
  • revealed — fires when element scrolls into viewport
  • intersect — uses IntersectionObserver (with root: and threshold: options)
  • every <time> — polling (e.g., every 2s)

Multiple triggers are comma-separated:

html
<input hx-post="/search"
       hx-trigger="input changed delay:500ms, keyup[key=='Enter'], load"
       hx-target="#results">

Not inherited.

hx-target — Where the Response Goes

CSS selector for the element that receives the response HTML. Defaults to the element making the request.

Extended selectors:

  • this — the element itself
  • closest <sel> — nearest ancestor matching selector
  • find <sel> — first descendant matching selector
  • next / next <sel> — next sibling (optionally matching selector)
  • previous / previous <sel> — previous sibling
html
<button hx-get="/info" hx-target="closest .card">Load</button>
<button hx-delete="/item/1" hx-target="closest tr">Delete</button>

Inherited.

hx-swap — How Content is Replaced

Controls the swap strategy. Default: innerHTML.

ValueDescription
innerHTMLReplace inner content of target
outerHTMLReplace the entire target element
textContentReplace text content (no HTML parsing)
beforebeginInsert before target
afterbeginInsert at start of target
beforeendInsert at end of target
afterendInsert after target
deleteDelete the target element
noneDo nothing with the response

Swap modifiers (appended with space):

  • swap:<time> — delay before swap (e.g., swap:1s for fade-out animations)
  • settle:<time> — delay before settling (e.g., settle:1s for fade-in)
  • transition:true — use View Transitions API
  • ignoreTitle — don't update page title
  • scroll:top / scroll:bottom — scroll target after swap
  • show:top / show:bottom — scroll element into view
  • focus-scroll:true/false — scroll focused element into view
html
<button hx-delete="/item" hx-swap="outerHTML swap:1s">Delete with fade</button>

Inherited.

hx-swap-oob — Out of Band Swaps

Allows response elements to update multiple parts of the page simultaneously. Add hx-swap-oob="true" (or a swap strategy) to elements in the response that should be swapped into their matching id location.

html
<!-- Server response can include: -->
<div id="main-content">Primary content here</div>
<div id="notification-count" hx-swap-oob="true">5</div>
<div id="sidebar" hx-swap-oob="outerHTML">Updated sidebar</div>

Use <template> to wrap elements that can't exist standalone (like <tr>, <td>, <option>):

html
<template><tr id="row-1" hx-swap-oob="true"><td>Updated</td></tr></template>

Not inherited.

hx-vals — Additional Request Parameters

Add extra values to requests in JSON format:

html
<button hx-post="/action" hx-vals='{"key": "value"}'>Go</button>

Dynamic values with js: prefix:

html
<button hx-post="/action" hx-vals='js:{timestamp: Date.now()}'>Go</button>

Inherited. Child values override parent values.

hx-include — Include Extra Inputs

Include input values from other elements:

html
<button hx-post="/search" hx-include="#search-form">Search</button>
<button hx-post="/save" hx-include="closest form">Save</button>

hx-select and hx-select-oob — Cherry-pick Response Content

hx-select picks a portion of the response to swap. hx-select-oob picks portions for out-of-band swaps elsewhere on the page.

html
<div hx-get="/page" hx-select="#content" hx-select-oob="#sidebar,#nav">

Both inherited.

Important Patterns

Inheritance

Most htmx attributes inherit from parent elements. Place shared attributes on a container:

html
<div hx-target="#result" hx-swap="outerHTML" hx-indicator="#spinner">
  <button hx-get="/one">One</button>
  <button hx-get="/two">Two</button>
</div>

Control with hx-disinherit (disable) or hx-inherit (enable when globally disabled). HTTP verb attributes (hx-get, hx-post, etc.) and hx-trigger are never inherited.

Loading Indicators

html
<button hx-get="/data" hx-indicator="#spinner">Load</button>
<span id="spinner" class="htmx-indicator">Loading...</span>

htmx adds htmx-request class to the indicator during requests. Default CSS transitions opacity from 0 to 1.

CSS Transitions & Animations

htmx applies CSS classes at different lifecycle stages:

  • htmx-request — during the request (on the indicator or triggering element)
  • htmx-swapping — during the swap phase
  • htmx-settling — during the settling phase
  • htmx-added — on newly added content before settling

Use these with CSS transitions for smooth animations:

css
tr.htmx-swapping td { opacity: 0; transition: opacity 1s ease-out; }
.htmx-added { opacity: 0; }
#element { transition: opacity 300ms ease-in; }

Boosting

hx-boost="true" progressively enhances links and forms to use AJAX:

html
<nav hx-boost="true">
  <a href="/page1">Page 1</a>  <!-- Now uses AJAX -->
  <a href="/page2">Page 2</a>
</nav>

Confirmation and Prompts

html
<button hx-delete="/item/1" hx-confirm="Are you sure?">Delete</button>
<button hx-post="/rename" hx-prompt="Enter new name">Rename</button>

Prompt value is sent in the HX-Prompt request header.

Synchronization

Prevent race conditions between related requests:

html
<form hx-post="/validate" hx-sync="closest form:abort">
  <input hx-post="/validate-email" hx-sync="closest form:abort"/>
  <button type="submit">Submit</button>
</form>

Strategies: drop, abort, replace, queue first, queue last, queue all.

Inline Event Handling (hx-on)

html
<button hx-get="/data" hx-on::after-request="alert('Done!')">Load</button>
<form hx-on::after-request="if(event.detail.successful) this.reset()">

Double-colon :: is shorthand for htmx: prefix. this refers to the element, event is the event object.

Request and Response Headers

Request Headers (sent by htmx)

HeaderDescription
HX-RequestAlways "true"
HX-TriggerID of the triggered element
HX-Trigger-NameName of the triggered element
HX-TargetID of the target element
HX-Current-URLCurrent browser URL
HX-Boosted"true" if boosted
HX-PromptUser response to hx-prompt

Response Headers (sent by server)

HeaderDescription
HX-TriggerTrigger client-side events
HX-Trigger-After-SwapTrigger events after swap
HX-Trigger-After-SettleTrigger events after settle
HX-Push-UrlPush URL to browser history
HX-Replace-UrlReplace current URL
HX-RedirectFull page redirect
HX-LocationClient-side redirect (AJAX)
HX-RefreshFull page refresh
HX-ReswapOverride swap strategy
HX-RetargetOverride swap target
HX-ReselectOverride hx-select

HX-Trigger header can carry data:

HX-Trigger: {"showMessage": "Item deleted", "itemCount": "5"}

Listen for these events:

html
<div hx-trigger="showMessage from:body" hx-get="/notifications">

Response Handling

By default, 2xx responses are swapped, 4xx/5xx are not. This is configurable:

html
<meta name="htmx-config" content='{
  "responseHandling": [
    {"code": "204", "swap": false},
    {"code": "[23]..", "swap": true},
    {"code": "422", "swap": true, "error": true},
    {"code": "[45]..", "swap": false, "error": true}
  ]
}'>

A 204 No Content response causes no swap. For DELETE, return 200 with empty body to clear the element.

Security Considerations

  • htmx.config.selfRequestsOnly (default: true) — restricts AJAX to same domain
  • Use hx-disable on containers with user-generated content
  • hx-vals with js: prefix evaluates JavaScript — sanitize user input
  • Set CSP nonces via htmx.config.inlineScriptNonce and htmx.config.inlineStyleNonce
  • htmx.config.allowEval can be set to false for strict CSP

Configuration

Set via meta tag or JavaScript:

html
<meta name="htmx-config" content='{"defaultSwapStyle":"outerHTML"}'>

Key config options: defaultSwapStyle (default: innerHTML), defaultSettleDelay (default: 20ms), historyCacheSize (default: 10), selfRequestsOnly (default: true), globalViewTransitions (default: false).

Reference Files

For detailed information, consult these reference files:

  • references/attributes.md — Complete attribute reference with all options and edge cases
  • references/patterns.md — Common UI patterns with full HTML and server-side examples
  • references/extensions.md — SSE, WebSocket, Idiomorph, head-support, preload, response-targets, and building custom extensions
  • references/server-side.md — Server integration patterns, response headers, and framework examples

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Htmx AI skill do?

Expert guidance for building web applications with htmx — the library that gives HTML superpowers by extending it with attributes for AJAX, CSS transitions, WebSockets, and Server-Sent Events. Use this skill whenever the user is working with htmx attributes (hx-get, hx-post, hx-swap, hx-trigger, hx-target, etc.), building hypermedia-driven applications, writing server endpoints that return HTML fragments, implementing patterns like click-to-edit, infinite scroll, active search, lazy loading, inline validation, or any UI pattern that uses HTML-over-the-wire instead of JSON APIs. Also use thi...

Why use Htmx on TypingMind?

Because you install it once and use it with any model. Htmx is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Htmx in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/mintarasss/htmx-skill/tree/main/htmx. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Htmx?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Htmx?

As many as you like. As long as a model supports skills, you can use Htmx with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Htmx AI skill free?

Yes. It is published on GitHub by mintarasss under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇