All Attributes

Complete reference for all html-star data attributes

Complete reference for all html★ data attributes.

Request Attributes

AttributeValuesDescription
data-hrefURLExplicit URL (overrides href/action)
data-methodget, post, put, patch, deleteHTTP method
data-headersJSON objectAdditional request headers
data-includeCSS selector, "self"Include inputs in request

Response Attributes

AttributeValuesInheritsDescription
data-targetCSS selector, "self"✓Where to swap content
data-swapinner, outer, prepend, append, before, after, delete, none✓Swap strategy
data-selectCSS selector✓Extract fragment from response
data-oob(boolean)✗Process out-of-band swaps

Behavior Attributes

AttributeValuesInheritsDescription
data-triggerclick, submit, change, input, visible, load✗Event trigger
data-push(boolean)✓Push to browser history
data-replace(boolean)✓Replace history entry
data-confirmmessage string✓Show confirmation dialog
data-disable(boolean)✗Disable during request
data-transitionstrue, false✓Enable View Transitions
data-debouncemilliseconds✗Debounce delay for input trigger
data-instant(boolean)✓Navigate on mousedown instead of click
data-send-headers(boolean)✓Send target/select selectors as request headers
data-prefetchhover, hover:<ms>, visible, eager, false✓Prefetch strategy

Persistence Attributes

AttributeValuesInheritsDescription
data-persiststorage key✗Persist input value
data-persist-scopelocal, session✗Storage type

Streaming Attributes

AttributeValuesInheritsDescription
data-sseURL✗SSE endpoint
data-sse-eventscomma-separated names✗Named events to listen for
data-pollinterval (e.g., "5s")✗Polling interval

Caching Attributes

AttributeValuesInheritsDescription
data-cacheduration (30s, 5m, 1h, 1d), swr, swr:<duration>✓Cache GET responses
data-cache-storagememory, session✓Cache storage backend (default: memory)
data-cache-invalidatecomma-separated URL patterns✗Invalidate cache entries on non-GET success

Error & Loading Attributes

AttributeValuesInheritsDescription
data-error-targetCSS selector✓Element to show on request error
data-loading-targetCSS selector✓Element to show during request
data-loading-classCSS class name✓Class added to trigger + target during request
data-queuefirst, last, all✓Concurrent request behavior (default: last)
data-retry(boolean)✗Retry button inside error target

State Attributes (Set by html★)

These are set by html★ for CSS targeting:

AttributeWhen SetOn Element
[data-loading]Request in progressTrigger element
[data-swapping]Swap in progressTarget element
[data-success]Swap completed (2s)Target element
[data-error]Request failedTrigger element
[data-error-message]Error messageTrigger element
[data-sse-connected]SSE connectedSSE element
[data-sse-error]SSE errorSSE element

Meta Tag Configuration

Set defaults via meta tags:

JSON Configuration

For more advanced configuration, use a JSON script block. JSON config takes precedence over meta tags:

defaults apply globally (like meta tags, but in one place).

selectors apply to elements matching CSS selectors. When an element matches multiple selectors, all matching rules are checked. Selector-based rules take precedence over defaults.