1. Docs
  2. Reference

Attributes

The attributes and state every element has, whatever its tag: actions, gestures, bindings and readings.

Generated from the engine's spec (HAM 1.7.0), so it always matches what the engine reads.

Every element

NameWhat it does
@@show Remount on condition: the element is rebuilt fresh each time the condition becomes true.
Type: expression
@click Statements to run on tap. Same grammar as action.
Type: action
@for Repeat this element: "x in xs", where xs is a range ("1 to 10", "1..10", "0 to $count step 2", "10 down to 1"; bounds are expressions; an empty range renders nothing) or a list, map or model as <@foreach in=> takes it. Each copy binds $x and $loop.index/iteration/first/last/count/even/odd, then evaluates its own @show, @text and the rest; copies splice into the parent with no box of their own. Live: the copies follow the bound $vars. Nothing to loop over renders nothing. key= names the row field that identifies a row (list sources). An id inside needs the row: id="tile-$x".
Type: expression · Also @each
@for-* @for-<name>="xs": the same, naming the variable in the attribute: <list-tile @for-i="1 to 10" @text="$i">.
Type: expression · Also @each-*
@on.* Statements to run on an event: @on.change, @on.load, @on.shake, @on.revealed, @on.dismiss … @on.key.NAME: a TV remote (or keyboard) media / menu button (play, pause, playpause, stop, rewind, fastforward, next, previous, menu, info, channelup, channeldown) pressed while focus is in the element (bubbling up, as keydown), or with nothing focused, on the screen; @on.key.left / right / up / down runs instead of moving focus. @on.focus / @on.blur: focus taken / lost; @on.dwell[.ms]: focus held 1200 ms (or ms), once.
Type: action
@opacity Reactive opacity, 0 to 1.
Type: expression
@repeat Repeat this element N times, binding $i = 1..N: alias of @for-i="1 to N".
Type: number
@show Reactive visibility. A hidden element releases its layout space but keeps its state.
Type: expression
@template Set by the engine on text with @{expr} parts (write @{…} in the text, not this attribute): the text re-renders live.
Type: string
@text Reactive text content: "$count items", math, and \$id.prop references. Empty, a <p> takes no space (as an empty block in CSS); a <text> keeps its line.
Type: expression
action What happens on the trigger: a URL to fetch, or ;-separated statements (media #id.command, $var = expr, prefix: commands, if/then/else).
Type: action
action-* Action for one trigger or event: action-swipeleft, action-longpress, action-created, action-dismiss …
Type: action
actions JSON array of {action, trigger, target} objects: several actions on one element.
Type: string
aria-label The accessible name of any element (what a screen reader says); wins over title.
Type: string
autofocus This tappable element has focus when the screen opens (a TV app's first button).
Type: boolean
bar On a navigating element (navigate: / <navigate>): none = the pushed page gets no bar. A page with a top-level <app-bar>, <screen> or <header> gets none anyway.
Type: enum · none
cancel-label The confirm dialog's cancel button (on <dialog>: its own button).
Type: string
checked On a switch, checkbox or radio: the state, or a binding (checked="$var").
Type: expression
confirm Ask before a tap or click runs the element's action (htmx hx-confirm): a built-in dialog with this message ($vars interpolate); Cancel does nothing, the confirm button runs it. On a button, link (<a href> too), <navigate>, a block with action= or @click / @on.tap. Presentation and modifiers in confirm-style, or as confirm:<presentation>[:<modifier>]. (<dismissible> keeps its own confirm=, a condition.)
Type: string
confirm-icon An icon atop the confirm dialog (Material; iOS alerts have none).
Type: string
confirm-label The confirm dialog's confirm button (on <dialog>: its own button).
Type: string
confirm-style How confirm asks: alert (a centered platform alert, Cupertino on iOS / macOS, Material elsewhere), sheet (alias bottom: an action sheet / bottom sheet), popover (anchored to the element on a wide screen, an alert on a phone); none given: alert, but destructive on iOS / macOS is a sheet. Modifiers destructive (a red confirm button, Cancel focused) and blur (the page behind blurred). Space-separated: "sheet destructive". hype check: a destructive confirm whose confirm-label is OK should name the action.
Type: string
confirm-title The confirm dialog's title (none by default).
Type: string
confirm:* confirm with its presentation and modifiers in the name: confirm:sheet="…", confirm:sheet:destructive="…", confirm:popover:blur="…". The same as confirm="…" confirm-style="sheet destructive".
Type: string
data-* Declares a variable scoped to the element, like var-*.
Type: string
defaults Per-element override of the tag defaults: none skips them for this element; a token list replaces them.
Type: string
delay Extra milliseconds to wait after the fetch before swapping.
Type: number
device:ignore Skip the element on these device tags.
Type: string · Also device-ignore
device:show Build the element only on these device tags (ios, android, tablet, watch …).
Type: string · Also device-show
dismiss true makes any element swipe-to-dismiss (fires dismiss). For list rows prefer <dismissible>.
Type: boolean
dismiss-direction Allowed swipe directions when dismiss=`true`.
Type: enum · horizontal, left, right, up, down, vertical
display Force the element onto its own line (block) or into the text flow (inline).
Type: enum · block, inline
flex Inside a <row> or a flex-row block: the share of leftover width the element takes. The style tokens flex-N / flex do the same.
Type: number
focus-group Remote / keyboard focus: the element remembers which of its focusable elements had focus last, and focus coming in from outside lands there (its first focusable the first time). A TV rail: Left from a row returns to the section last used.
Type: boolean
global-* Declares an app-wide variable.
Type: string
haptic Haptic feedback when the element is activated.
Type: enum · light, medium, heavy, selection
id Element id: a swap target (#id), and the owner of \$id.* state. Makes name= variables local to the element.
Type: string
include #id of another scope whose local variables this element's request also sends.
Type: string
indicator Loading indicator during the fetch: blank for a spinner, #id for a named <indicator>. Also loading.
Type: string · Also loading
key On an element with @for over a list: the row field that identifies a row (default id), so a changed list keeps each row's state. As key= on <@foreach>.
Type: string
label The element's accessible name: what VoiceOver / TalkBack read for it, and the name hype tree / hype tap find it by (aria-label). An icon-only <button> without one is named after its icon (add is "Add", remove is "Remove", shopping_cart is "Shopping cart"). Tags with a label of their own (a field's, a tab's, a chip's, a chart's) keep that meaning.
Type: string
method HTTP method for the fetch.
Type: enum · GET, POST, PUT, DELETE, PATCH
name On a form control: the variable the control writes its displayed value to ($name).
Type: string
parallax Scroll lag in px per 100px scrolled. Works on any element; parallax-cover grows it to hide the gap.
Type: number · Also parallax-cover
params What a request sends besides its own and form-scope fields: "$tab $q" adds those variables, "*" every global, "none" nothing, "not $x" everything but. Globals are not sent by default.
Type: string
persist With an id: a shared element. When a pushed page has an element with the same id and persist, this one flies from its box to that one (and back on back); the ids match after $ interpolation, one per page. Within a page, a swap bringing the id back glides it from its old place.
Type: boolean
remove-after Remove the element after this time (3s, 1.5s, 300ms, or ms), giving its space back, as @show does. An animate-fade-out-{ms} on it ends at the removal: a toast that fades and goes. With @show / @@show the time runs from each time the element appears, and a removed element is back when shown again.
Type: string · Also remove_after
scroll top: after the fetched content is swapped in, the page it sits in scrolls back to the top (a new list loaded into #main otherwise opens at the old scroll position).
Type: enum · top
select Swap only part of the response: select="#id" takes that element's content.
Type: string
show-ham none / off: per-element sugar for without=`show-ham`.
Type: string
source Where the action URL is read from.
Type: enum · network, file, folder
stream Server-sent events: while the element is mounted (a page pushed over it included; it closes when the element goes) it listens to the stream at this URL (text/event-stream; resolved like any request). Each event whose name is in stream-event is a complete HAM fragment swapped into the element with its swap= mode, at most once a frame; an event "vars" (a JSON object) sets $name for each key (the variable in scope where the element lives, else a new page variable); "close" ends the stream. Elements with the same URL share one connection; it pauses in the background and reconnects with Last-Event-ID. An element with an id publishes $id.connected. A stream sends events and data (a tap, a reading, a one-time HAM description); animate on the device (particles, animate-*, transitions). Never re-send a fragment on a timer to animate it.
Type: url · Also sse
stream-event The stream events this element takes (space separated); the SSE default name is message. key: an event named key presses the TV button its data names (up, down, left, right, ok, back, play, pause …, as key:), a phone as the remote; only for an element that lists it.
Type: string · Also sse-swap
style Style tokens, space separated. Tokens may carry condition prefixes (dark:, press:, ios:) and reference $variables.
Type: style
swap How the fetched content replaces the target. outer (default): the response replaces the target element itself; inner: only its children; after / before: next to the target, below / above it; append / prepend (htmx beforeend / afterbegin): inside the target, after / before its children (a <stack> gets a new layer); append-text (streams): the event text is added to the element text. On <navigate> (or navigate:), replace replaces the current page instead of pushing a new one. A URL fired from @on.* / action-* on an element without action=, and tab / rail lazy loads, default to inner.
Type: enum · inner, outer, before, after, append, prepend, delete, none, replace, append-text
swipe-threshold Swipe velocity threshold in px/s.
Type: number
tabindex Remote / D-pad / keyboard focus order, as in HTML: a tappable element (an action, a link) is focusable in reading order; 1, 2 … come first, in that order; -1 takes it out of the focus order.
Type: number
tap-effect Tap feedback effect for this element and its children: a type, optionally with :color and :size (ring:blue:60).
Type: enum · ring, dot, burst, none · Also tap_effect
target Where the fetched content goes: #id, or this. Defaults to the element itself or #main.
Type: string
title Page title when this element's action navigates to a new page (without one: an <h1> that opens the page, else none). On something you tap, its accessible name too (a tag whose title is its own content excepted).
Type: string
transition Swap animation: fade, slide-left, slide-right, slide-up, slide-down, scale, none, or shader-dissolve|radial|pixelate|morph (GPU shaders that ship with the engine; off on web, where the swap is instant). Without it (or transition-in/-out) a swap is instant. On a navigate: push the same names say how the page comes in (a shader-* name pushes as fade); without it, the platform's own push.
Type: string
transition-duration Swap (or navigate: push) animation duration in ms.
Type: number
transition-in The entering content's animation (same values as transition). On its own it turns the animation on; the leaving side fades.
Type: string · Also transition-enter
transition-out The leaving content's animation (same values as transition). On its own it turns the animation on; the entering side fades.
Type: string · Also transition-exit
transition-shader Shader for a reactive style change (dissolve, radial, pixelate). Not used by swaps: use transition="shader-…".
Type: string
trigger Event that starts the action: click, tap, doubletap, longpress (also OK / Enter held on a TV remote or keyboard), load, revealed, every {n}s, swipeleft/right/up/down, drag, shake, rotate, orientation, change, none; the gesture core on any element: pinch / twist (on lift; pinch.in/.out/.150, twist.30) and their live phases pinch.start/.move/.end, twist.start/.move/.end, touch (every phase) and touch.start/.move/.end/.cancel, tap.2fingers … tap.5fingers. Modifier: :delay-{n}ms.
Type: string
value On a form control: the value, or a one-way binding to any expression (value="$var", value="#id.value").
Type: expression
var-* Declares a variable scoped to the element: var-count="0" makes $count.
Type: string
with Restore behaviors deeper inside a subtree that stripped them with without=.
Type: string
without Strip inherited app-level behaviors from this subtree, space-separated (show-ham, tap-effect). Unknown keys warn.
Type: string · Also disinherit

State every element publishes

NameWhat it does
$id.connected With stream= / sse=: whether the stream is connected.
Type: boolean
$id.event The last event the element fired (change, flip, complete …); empty until one fires.
Type: string

Commands every element takes

NameWhat it does
#id.animate:effect Play a one-shot effect on the element now, again on each command: punch (alias pop: up to 120% and back in 200 ms), shake (±6 px, 500 ms) or shake-rotate (±3°), with the numbers its animate- token takes (#answer.animate:punch-150-120, #card.animate:shake-12-300). Paint-only; nothing under reduced motion. Without an effect: punch.

This page is also Markdown, and all of HAM is in llms.txt.