Logo de Htmx

Htmx

Communauté
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.

Présentation

Éditeurmintarasss
Dépôthtmx-skill
Nom de la compétencehtmx
Étoiles
47
Forks
2
Fichiers inclus
4
LicenceMIT
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont en simple Markdown, et non en code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • 4 fichiers inclus

    Des scripts, des modèles de documents et des références que le modèle peut consulter pendant son travail. Les fichiers sont en lecture seule et ne sont jamais exécutés.

  • Open source

    Publiée par mintarasss sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Htmx dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Collez l’URL du dossier de la compétence indiquée ci-dessous, puis confirmez.
    https://github.com/mintarasss/htmx-skill/tree/main/htmx
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter → Via URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

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
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Htmx dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Htmx dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, Htmx n’est pas lié au modèle pour lequel cette compétence a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

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

Fichiers inclus

Le modèle lit ces fichiers à la demande lorsque la compétence est chargée. Ils sont accessibles en lecture et ne sont jamais exécutés.

Foire aux questions

À quoi sert la compétence IA 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 thi...

Pourquoi utiliser Htmx sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Htmx se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Htmx dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/mintarasss/htmx-skill/tree/main/htmx. TypingMind lit le fichier SKILL.md, regroupe les fichiers associés et installe le tout sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Htmx ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Htmx ?

Autant que vous le souhaitez. Tant qu’un modèle prend en charge les compétences, vous pouvez utiliser Htmx avec lui : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Htmx est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par mintarasss sous licence MIT. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, modèles de documents ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇