generate-htmx-component

Generates server-driven HTML fragments using HTMX attributes and Tailwind utility classes.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill generate-htmx-component-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-htmx-component
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/ui_skills/generate-htmx-component
Command: npx skills add https://github.com/asarchami/dotfiles --skill generate-htmx-component-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building interactive UI elements that update without full page reloads often requires heavy JavaScript frameworks. This Skill produces lightweight, server-driven HTML fragments using HTMX attributes and Tailwind classes, keeping frontend logic minimal and server-controlled. ## Core Features & Use Cases - HTMX Fragment Generation: Creates HTML-only components with hx-get, hx-post, hx-target, and hx-swap attributes for dynamic server-driven interactions. - Correct Swap & Validation Patterns: Applies proper hx-swap strategies, hx-swap-oob multi-target updates, and HTTP status codes (200, 422, 404, 400) for form validation flows. - Minimalist Tailwind Styling: Styles components with an off-white, light gray, single-accent palette using standard Tailwind utility classes. - Use Case: Build a form card that submits via hx-post, returns validation errors inline with HTTP 422, and updates a list via hx-swap-oob — all without writing any client-side JavaScript. ## Quick Start Generate an HTMX contact form component that posts to the server and displays inline validation errors without reloading the page.

Frequently Asked Questions about generate-htmx-component

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

FAQPage Schema
How do I build dynamic UI components with HTMX?

Use HTMX attributes like hx-get, hx-post, hx-target, and hx-swap directly in HTML fragments. The server detects the HX-Request header and returns partial HTML fragments instead of JSON, which HTMX swaps into the page.

How to handle form validation errors in HTMX?

Return the same form fragment with inline error messages and HTTP status 422 instead of redirecting. HTMX renders the error response in place, preserving user input and showing validation feedback without a page reload.

What is the difference between hx-swap innerHTML and outerHTML?

innerHTML replaces the content inside the target element, while outerHTML replaces the entire target element itself. Use beforeend or afterend for insertion and delete for removal, depending on the update pattern needed.

Can HTMX update multiple elements from one server response?

Yes, use hx-swap-oob (out-of-band) to update multiple UI targets from a single fragment response. Mark secondary elements in the response with hx-swap-oob and matching IDs so HTMX swaps them alongside the primary target.

When should I avoid using HTMX for frontend interactions?

Avoid HTMX when building highly stateful client-side applications like real-time collaborative editors or complex SPAs. HTMX suits server-driven fragment updates, not rich client-side state management.