htmx-interaction-patterns

Build dynamic web interfaces with htmx using server-rendered HTML fragments and attribute-driven requests.

Updated May 16, 2026
One-click install
npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill htmx-interaction-patterns-organvm-i-theoria
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: htmx-interaction-patterns
Source: https://github.com/organvm-i-theoria/_agent-ontology/tree/main/.agents/skills/htmx-interaction-patterns
Command: npx skills add https://github.com/organvm-i-theoria/_agent-ontology --skill htmx-interaction-patterns-organvm-i-theoria

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building interactive web UIs typically requires writing client-side JavaScript for AJAX calls, DOM updates, and state management. This Skill provides htmx patterns that deliver dynamic behavior—partial page updates, lazy loading, infinite scroll, and server-sent events—using only HTML attributes and server-rendered fragments. ## Core Features & Use Cases - Attribute-Driven Requests: Use hx-get, hx-post, hx-target, hx-swap, and hx-trigger to issue HTTP requests and update the DOM without JavaScript. - Common Interaction Patterns: Ready-made recipes for debounced search, inline editing, infinite scroll, lazy loading, confirmation dialogs, and server-sent events. - Server-Side Integration: Patterns for returning partial fragments vs full pages, using HX-Trigger/HX-Retarget response headers, and out-of-band swaps to update multiple elements. - Use Case: Add live search to a FastAPI app by wiring an input with hx-get and a 300ms debounce, then returning an HTML fragment from the endpoint—no frontend build step required. ## Quick Start Ask the AI to add an htmx-powered debounced search input that fetches results from a server endpoint and swaps them into a target div.

Frequently Asked Questions about htmx-interaction-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add dynamic search to a page with htmx?▼

Add hx-get pointing to your search endpoint, hx-trigger="input changed delay:300ms" for debouncing, and hx-target for the results container. The server returns an HTML fragment that htmx swaps into the target element.

How does htmx infinite scroll work?▼

Place an element with hx-trigger="revealed" and hx-get for the next page at the end of your list. When it scrolls into view, htmx fetches the next items, and the server response includes a new trigger element for the following page.

Can htmx endpoints return JSON instead of HTML?▼

No, htmx endpoints should return rendered HTML fragments, not JSON. Returning JSON is an anti-pattern because htmx swaps response content directly into the DOM; keep rendering on the server.

How do I handle both htmx and normal browser requests?▼

Check for the HX-Request header on the server. If present, return only the HTML fragment; otherwise return the full page. This keeps URLs bookmarkable and supports progressive enhancement.

How do I update multiple elements from one htmx response?▼

Use out-of-band swaps by adding hx-swap-oob="true" to extra elements in the response. htmx updates those elements by id in addition to the primary swap target, letting one request refresh several page regions.