htmx-auto-refresh-preservation
OfficialKeep HTMX auto-refresh without losing user state.
System Documentation
What problem does it solve?
Auto-refreshing HTMX regions commonly reset focus, close selects, collapse details/accordions, and jump scroll positions on every update. This Skill provides a prescriptive setup using Idiomorph morph swaps and event hooks so polling or SSE updates do not disrupt in-progress user interactions.
Core Features & Use Cases
- State-Safe Morph Swaps: Enforces morph:innerHTML/outerHTML with hx-ext="morph" and Idiomorph defaults (ignoreActive, ignoreActiveValue) to preserve focus and input values.
- UI State Preservation: Prevents <details> from collapsing via beforeAttributeUpdated and restores scroll positions with htmx:beforeSwap/afterSwap handlers.
- Robust Interaction Patterns: Offers selective morph exclusion and conditional polling to avoid jarring updates while users type, select, or drag.
- Use Case: A dashboard panel that polls every 2s for updated job statuses while a user edits a form and reads logs in a scrollable container; inputs stay focused, selects remain open, details stay expanded, and scroll positions are preserved.
Quick Start
Enable hx-ext="morph", include idiomorph-ext.min.js, set Idiomorph defaults for ignoreActive and ignoreActiveValue, use morph:innerHTML on polling regions, and add callbacks to preserve details and scroll positions.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: htmx-auto-refresh-preservation Download link: https://github.com/sandgardenhq/sgai/archive/main.zip#htmx-auto-refresh-preservation Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.