Complete reference for all html★ data attributes.
Request Attributes
| Attribute | Values | Description |
|---|---|---|
data-href | URL | Explicit URL (overrides href/action) |
data-method | get, post, put, patch, delete | HTTP method |
data-headers | JSON object | Additional request headers |
data-include | CSS selector, "self" | Include inputs in request |
Response Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-target | CSS selector, "self" | ✓ | Where to swap content |
data-swap | inner, outer, prepend, append, before, after, delete, none | ✓ | Swap strategy |
data-select | CSS selector | ✓ | Extract fragment from response |
data-oob | (boolean) | ✗ | Process out-of-band swaps |
Behavior Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-trigger | click, submit, change, input, visible, load | ✗ | Event trigger |
data-push | (boolean) | ✓ | Push to browser history |
data-replace | (boolean) | ✓ | Replace history entry |
data-confirm | message string | ✓ | Show confirmation dialog |
data-disable | (boolean) | ✗ | Disable during request |
data-transitions | true, false | ✓ | Enable View Transitions |
data-debounce | milliseconds | ✗ | 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-prefetch | hover, hover:<ms>, visible, eager, false | ✓ | Prefetch strategy |
Persistence Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-persist | storage key | ✗ | Persist input value |
data-persist-scope | local, session | ✗ | Storage type |
Streaming Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-sse | URL | ✗ | SSE endpoint |
data-sse-events | comma-separated names | ✗ | Named events to listen for |
data-poll | interval (e.g., "5s") | ✗ | Polling interval |
Caching Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-cache | duration (30s, 5m, 1h, 1d), swr, swr:<duration> | ✓ | Cache GET responses |
data-cache-storage | memory, session | ✓ | Cache storage backend (default: memory) |
data-cache-invalidate | comma-separated URL patterns | ✗ | Invalidate cache entries on non-GET success |
Error & Loading Attributes
| Attribute | Values | Inherits | Description |
|---|---|---|---|
data-error-target | CSS selector | ✓ | Element to show on request error |
data-loading-target | CSS selector | ✓ | Element to show during request |
data-loading-class | CSS class name | ✓ | Class added to trigger + target during request |
data-queue | first, 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:
| Attribute | When Set | On Element |
|---|---|---|
[data-loading] | Request in progress | Trigger element |
[data-swapping] | Swap in progress | Target element |
[data-success] | Swap completed (2s) | Target element |
[data-error] | Request failed | Trigger element |
[data-error-message] | Error message | Trigger element |
[data-sse-connected] | SSE connected | SSE element |
[data-sse-error] | SSE error | SSE element |
Meta Tag Configuration
Set defaults via meta tags:
HTML
<head> <meta name="htmlstar:target" content="#main"> <meta name="htmlstar:swap" content="inner"> <meta name="htmlstar:transitions" content="true"> <meta name="htmlstar:debounce" content="300"></head>
JSON Configuration
For more advanced configuration, use a JSON script block. JSON config takes precedence over meta tags:
HTML
<script type="htmlstar/config">{ "defaults": { "target": "#main", "swap": "inner", "transitions": "true" }, "selectors": { "nav a": { "push": "true", "prefetch": "hover" }, "form": { "swap": "outer" }, ".dashboard-widget": { "cache": "swr:1m" } }}</script>
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.