on input from .quantity set #total.innerText to (the value of #price as Number) * (my value as Number)
Copy To Clipboardbothclipboard
Copy text to clipboard with feedback
on click call navigator.clipboard.writeText(#code.innerText) put "Copied!" into me wait 2s put "Copy" into me
Decrement Counterbothcounters
Decrement a numeric counter element
on click decrement #counter's textContent
Default Valuebothdata
Set default value if not present
on load default my @data-count to "0"
Disable Form On Submitbothforms
Disable submit button while processing
on submit add @disabled to <button/> in me put "Submitting..." into <button/> in me
Document Readybothwindow-events
Initialize app when element loads
on load call initializeApp()
Draggable Behaviorbothbehavior
Makes element draggable with pointer events. Use: install Draggable(dragHandle: ".titlebar")
behavior Draggable(dragHandle)
on pointerdown(clientX, clientY) from (dragHandle or me)
halt the event
trigger draggable:start
set xoff to clientX - my offsetLeft
set yoff to clientY - my offsetTop
repeat until event pointerup from document
wait for pointermove(clientX, clientY) or
pointerup(clientX, clientY) from document
add { left: ${clientX - xoff}px; top: ${clientY - yoff}px; }
trigger draggable:move
end
trigger draggable:end
end
end
Dropdown Togglebothui-components
Toggle dropdown menu visibility
on click toggle .open on next .dropdown-menu halt
Event Debouncebothevents
Debounce input for search
on input debounced at 300ms fetch `/api/search?q=${my value}` as json then put it into #results
Event Oncebothevents
Handle event only once
on first click add .initialized to me call setup()
Event Throttlebothevents
Throttle scroll handler
on scroll throttled at 100ms call updateScrollPosition()
Exclusive Accordionbothui-components
Accordion where only one panel is open
on click remove .open from .accordion-item add .open to closest .accordion-item
Fade Out And Removebothanimation
Fade element out then remove from DOM
on click transition opacity to 0 over 300ms then remove me
Fetch Databothasync
Fetch data from an API and display it
on click fetch /api/data then put it into #result
Fetch JSONbothasync
Fetch JSON data and use a property
on click fetch /api/user as json then set #name.innerText to it.name
Fetch With Auth Headerbothasync
Fetch with custom headers and parse the response as JSON
on click fetch /api/me with headers:{Authorization:`Bearer ${$token}`} as JSON then put it.name into me
Fetch With Error Handlingbothasync
Handle API errors by checking response body
on click fetch /api/data as json then if it.error put it.error into #error else put it.data into #result end
Fetch With Loading Statebothasync
Show loading indicator during fetch
on click add .loading to me fetch /api/data then remove .loading from me put it into #result
Fetch With Methodbothasync
Submit form data via POST
on submit fetch /api/form with method:"POST", body:form
Fetch Without Throwingbothasync
Fetch without throwing on errors; check the result before using it
on click fetch /api/users as JSON do not throw then if it set $users to it end
First In Collectionbothnavigation
Focus first input in parent form
on click focus first <input/> in closest <form/>
Focus Elementbothfocus
Focus an input element
on click focus #input
Focus Trapbothaccessibility
Trap focus within modal
on keydown[key=="Tab"] from .modal if target matches last <button/> in .modal focus first <button/> in .modal halt end
Get Attribute (Possessive Dot)bothhyperfixi-extensions
Call getAttribute using possessive dot notation (HyperFixi extension)
on click put my.getAttribute("data-id") into #output
Get Input Value (Possessive Dot)bothhyperfixi-extensions
Mirror input value using possessive dot notation (HyperFixi extension)
on input put my.value into #preview
Get Valuebothdata
Get a value and use it
on click get #input.value then log it
Go Backbothnavigation
Navigate back in history
on click go back
Go To URLbothnavigation
Navigate to a URL
on click go to url "/page"
Halt Eventbothcontrol-flow
Stop event propagation
on click halt the event then toggle .active
Hide Elementbothvisibility
Hide an element
on click hide #modal
Hide With Transitionbothvisibility
Hide element with opacity transition
on click hide me with *opacity
If Conditionbothcontrol-flow
Conditional execution based on state
on click if I match .active then remove .active else add .active end
If Element Existsbothcontrol-flow
Check if element exists before action
on click if #modal exists show #modal else make a <div#modal/> put it into body end
If Matches Selectorbothcontrol-flow
Check if element matches selector
on click if I match .disabled halt else toggle .active end
If Value Emptybothcontrol-flow
Validate empty input
on blur if my value is empty add .error to me put "Required" into next .error-message end
Walks up the parent chain to find ^count and writes the nearest defining ancestor
on click increment ^count
Increment a Sibling Counterbothcounters
Increment the text of the output element just before this one
on click increment the textContent of the previous <output/>
Inline JavaScriptbothadvanced
Execute inline JavaScript
on click js console.log("from js") end
Input Mirrorbothforms
Mirror input value to another element
on input put my value into #preview
Input Validationbothforms
Validate input on blur
on blur if my value is empty add .error to me else remove .error from me end
Install Behaviorbothbehavior
Install a reusable behavior on an element. Replace "Draggable" with any defined behavior name (e.g., Sortable, Closeable).
install Draggable
Intercept: Cache Strategiesservice-workers
Service worker DSL with precaching, per-route strategies, and offline fallback
intercept /
precache /, /style.css, /app.js as "v1"
on /api/* use network-first
on *.css, *.js use cache-first
on * use stale-while-revalidate
offline fallback /offline.html
end
Its Value (Possessive Dot)bothhyperfixi-extensions
Access result property using its.property syntax (HyperFixi extension)
on click fetch /api/data then put its.name into #result
Key Combinationbothevents
Handle Shift+Enter key combo
on keydown[key=="Enter"] if event.shiftKey call submitAndContinue() end
Key Filter With `is`bothevents
Filter keyboard events using the modern `is` comparison syntax
on keyup[key is 'Escape'] clear me
Last In Collectionbothnavigation
Scroll to last message in chat
on click scroll to last <.message/> in #chat
Live Block Fed By A Handlerbothreactivity
A handler writes a global; a live block that reads it re-renders on every write
<button _="on click set $count to ($count or 0) + 1">+1</button>
<div _="live put $count into me end"></div>
Live Block With Multiple Dependenciesbothreactivity
Body re-runs only when one of its tracked reads ($price or $quantity) changes
live put `${$price * $quantity}` into #total end
Live Derived Valuebothreactivity
Reactively update content whenever a tracked dependency changes
live put `Count: ${$count}` into me end
Log Elementbothdebugging
Log the current element to console
on click log me
Log Valuebothdebugging
Log a message to the console
on click log "Button clicked!"
Make Elementbothdom-manipulation
Create a new element dynamically
on click make a <div.card/> then put it into #container
Make Toast Elementbothtemplates
Create a new element, populate its content, and append it to the document
on click make a <div.toast/> then put 'Saved!' into it then put it at end of body
Call method on property using possessive dot notation (HyperFixi extension)
on input put my.value.toUpperCase() into #preview
Morph Fetched HTMLbothmorphing
Fetch HTML and morph the DOM in place, preserving focus and form state
on click fetch /api/items then morph #list to it
Morph Form Without Losing Focusbothmorphing
Morph a form after submit so users keep focus, scroll position, and unsaved values
on submit fetch /api/save then morph (closest <form/>) to it
Morph Rendered Templatebothmorphing
Render a template then morph it into the target element
on click render #row with row: $data then morph #target to it
Multiple Event Handlersbothevents
Handle multiple events with one handler
on click or keypress[key=="Enter"] toggle .active
Negated Conditionbothcontrol-flow
Run a command only when a condition does not hold
on click if I do not match .disabled toggle .selected
Next Elementbothnavigation
Select and modify next sibling element
on click add .highlight to next <li/>
Null-Safe Property Chainbothhyperfixi-extensions
A property chain is null-safe: a missing link gives null instead of throwing
on click log my.dataset.customValue
Open Modalbothui-components
Open modal and prevent body scroll
on click show #modal add .modal-open to body
POST With Method And Bodybothasync
POST to an endpoint by passing method and body as fetch options
on click fetch /api/users with method:"POST", body:"name=Joe"
Pick Text Rangebothdom-manipulation
Select a text range within an input or contenteditable using the pick command
on click pick characters 0 to 5 of #note
Prevent Form Submitbothforms
Prevent form submission and validate
on submit halt the event call validateForm() if result is false log "Invalid form" end
Previous Elementbothnavigation
Select and modify previous sibling element
on click remove .highlight from previous <li/>
Pseudo-Commandbothadvanced
Call a method on an element as if it were a command
on load click() me
Put Afterbothdom-manipulation
Insert content after the current element
on click put "<p>New</p>" after me
Put Beforebothdom-manipulation
Insert content before the current element
on click put "<p>New</p>" before me
Put Contentbothdom-manipulation
Replace the content of the current element
on click put "Done!" into me
Reactive Array Mutationbothreactivity
Mutate a reactive array; live blocks reading it re-render automatically
on click call $items.push(`item ${$items.length + 1}`)
Read DOM-Scoped Variable From Another Elementbothreactivity
Read a ^name variable scoped to a specific element instead of walking up from `me`
on click put ^count on #host into me
Receive Custom Eventbothevents
Receive a custom event and update the receiving element's content
on hello put 'Got it!' into me
Removable Behaviorbothbehavior
Removes element on click with optional confirmation and fade effect. Use: install Removable(confirmRemoval: true, effect: "fade")
behavior Removable(triggerEl, confirmRemoval, effect)
on click from (triggerEl or me)
if confirmRemoval
js(me)
if (!window.confirm("Are you sure?")) return "cancel";
end
if it is "cancel"
halt
end
end
trigger removable:before
if effect is "fade"
transition opacity to 0 over 300ms
end
trigger removable:removed
remove me
end
end
Remove Classbothclass-manipulation
Remove a CSS class from the current element when clicked
on click remove .highlight from me
Remove Class From Allbothclass-manipulation
Remove a CSS class from all matching elements
on click remove .active from .items
Remove Elementbothdom-manipulation
Remove the current element from the DOM
on click remove me
Render Template With Databothtemplates
Render a named template element with data, then insert the HTML into the DOM
on click render #user-list with users: $data then put it into #container
Repeat For Eachbothloops
Iterate over a collection
on click repeat for item in .items add .processed to item
Repeat Foreverbothloops
Infinite animation loop
on load repeat forever toggle .pulse wait 1s end
Repeat Timesbothloops
Repeat an action multiple times
on click repeat 3 times append "<p>Line</p>" to me
Repeat Until Eventbothloops
Repeat action while button is held
on mousedown repeat until event mouseup increment #counter's textContent wait 100ms end
Repeat While Conditionbothloops
Repeat while condition is true
on click repeat while #counter.innerText < 10 increment #counter's textContent wait 200ms end
Resizable Behaviorbothbehavior
Makes elements resizable by dragging. Use: install Resizable(minWidth: 100, minHeight: 100)
behavior Resizable(minWidth, minHeight, maxWidth, maxHeight)
on pointerdown(clientX, clientY) from me
halt the event
trigger resizable:start
set startWidth to my offsetWidth
set startHeight to my offsetHeight
set startX to clientX
set startY to clientY
repeat until event pointerup from document
wait for pointermove(clientX, clientY) or pointerup(clientX, clientY) from document
set newWidth to (startWidth + clientX) - startX
set newHeight to (startHeight + clientY) - startY
if newWidth < minWidth then set newWidth to minWidth end
if newWidth > maxWidth then set newWidth to maxWidth end
if newHeight < minHeight then set newHeight to minHeight end
if newHeight > maxHeight then set newHeight to maxHeight end
set my *width to newWidth + "px"
set my *height to newHeight + "px"
trigger resizable:resize
end
trigger resizable:end
end
end
Resize Handlerbothwindow-events
Handle window resize with debounce
on resize from window debounced at 200ms call adjustLayout()
Screen Reader Announcementbothaccessibility
Announce message to screen readers
on success put event.detail.message into #sr-announce set @role of #sr-announce to "alert"
Scroll Handlerbothwindow-events
Add sticky class on scroll
on scroll from window if window.scrollY > 100 add .sticky to #header else remove .sticky from #header end
Send Custom Eventbothevents
Dispatch a custom event to another element
on click send refresh to #widget
Send Custom Event To Formbothevents
Dispatch a custom event named hello to all form elements
on click send hello to <form/>
Send Event With Detailbothevents
Send an event with data payload
on click send update(value: 42) to #target
Send To Named Socketbothrealtime
Send a message to a previously-declared WebSocket from a click handler
on click send "hello" to ChatSocket
Server-Sent Events Sourcehyperscriptrealtime
Subscribe to a server-sent events endpoint and append messages to the DOM
eventsource ChatStream from /events
on message
put it into #messages
end
end
Set Attributebothdom-manipulation
Set an attribute on the current element
on click set @disabled to true
Set DOM-Scoped Variable On Parentbothreactivity
Declare a ^name variable on this element; descendants can read and write it
on load set ^count to 0
Set Opacitybothcss-styles
Set CSS opacity using possessive syntax
on click set my *opacity to 0.5
Set Stylebothdom-manipulation
Set a CSS style property
on click set my *background to "red"
Set Style Property on Another Elementbothcss-styles
Set a style property on a different element via the of-possessive
on click set the *background-color of #theme to "#ff6600"
Set Text (Possessive Dot)bothhyperfixi-extensions
Set text content using possessive dot notation (HyperFixi extension)
on click set my.textContent to "Done!"
Set Text Contentbothdom-manipulation
Set the text content of an element by ID
on click set #output.innerText to "Hello World"
Set Transformbothcss-styles
Set CSS transform property
on click set my *transform to "rotate(45deg)"
Set innerHTML (Possessive Dot)bothhyperfixi-extensions
Set innerHTML using possessive dot notation (HyperFixi extension)
on click set my.innerHTML to "<strong>Updated!</strong>"
Settle Animationsbothanimation
Wait for CSS animations to complete
on click add .animate then settle then remove .animate
Show Elementbothvisibility
Show a hidden element
on click show #modal
Show With Transitionbothvisibility
Show element with opacity transition
on click show #modal with *opacity
Slide Togglebothanimation
Slide a panel open/closed — pair .collapsed with a CSS max-height transition
on click toggle .collapsed on next .panel
Sortable Behaviorbothbehavior
Makes child elements reorderable via drag-and-drop. Use: install Sortable(dragClass: "dragging")
behavior Sortable(dragClass)
on pointerdown(clientY) from me
set item to the target.closest("li")
if item is null
exit
end
halt the event
set cls to dragClass or "sorting"
add .{cls} to item
trigger sortable:start on me
repeat until event pointerup from document
wait for pointermove(clientY) or pointerup(clientY) from document
trigger sortable:move on me
end
remove .{cls} from item
trigger sortable:end on me
end
end
Stagger Animationbothanimation
Staggered entrance animation
on load repeat for item in .item index i add .visible to item wait 100ms end
Submit Form As FormDatabothasync
Serialize the closest form as FormData and POST it
on submit js(me) return new FormData(me.closest('form')) end then fetch /api/submit with method:"POST", body:it
Swap Contentbothdom-manipulation
Swap two elements in the DOM
on click swap #a with #b
Swap Content With View Transitionbothdom-manipulation
Swap two elements inside a view transition (document.startViewTransition) so the browser animates the change
on click start view transition swap #a with #b end
Tab Navigationbothui-components
Basic tab switching with active state
on click remove .active from .tab add .active to me
Tab With Content Panelbothui-components
Tab that shows associated content panel
on click remove .active from .tab add .active to me hide .tab-panel show the next <div.tab-panel/>
Take Class From Siblings (Tabs)bothdom-manipulation
Take a class from sibling elements and apply it to the current one (canonical tabs idiom)
on click take .active from .tab-button for me
Tell Another Elementbothevents
Run a sequence of commands on another element using tell
on click tell #panel add .open then wait 200ms then add .visible
Tell Commandbothbehavior
Tell another element to execute a command
on click tell #modal show
Template Literal Interpolationbothtemplates
Use backtick template literals to interpolate values into HTML
on click set my innerHTML to `<li>${$item.name}</li>`
Toggle ARIA Expandedbothaccessibility
Toggle ARIA expanded state
on click toggle @aria-expanded on me toggle .open on next .panel
Toggle Classbothclass-manipulation
Toggle a CSS class on the current element when clicked
on click toggle .active
Toggle Class On Other Elementbothclass-manipulation
Toggle a CSS class on another element
on click toggle .open on #menu
Toggle Class Temporarilybothclass-manipulation
Toggle a CSS class, then revert it after a duration
on click toggle .loading for 2s
Toggle Visibilitybothvisibility
Toggle the hidden attribute on an element
on click toggle @hidden on #panel
Transition Background Colorbothcss-styles
Animate background color change
on click transition *background-color to "blue" over 500ms
Transition Opacitybothanimation
Animate opacity then remove the element
on click transition opacity to 0 over 500ms then remove me
Transition Transformbothanimation
Animate transform property
on click transition transform to "scale(1.2)" over 300ms
Trigger Eventbothevents
Trigger a custom event when the element loads
on load trigger init
Two-Way Bind Two Inputsbothreactivity
Share a global between two inputs by binding both to it; edits in either propagate to the other
bind $name to #input-a bind $name to #input-b
Two-Way Bindingbothdata
Update display as input changes
on input from #firstName set #greeting.innerText to "Hello, " + my value
Wait For Eventbothtiming
Wait for a DOM event to fire
on click wait for transitionend
Wait Then Executebothtiming
Wait for a duration before executing a command
on click wait 2s then remove me
Web Worker Definitionhyperscriptrealtime
Define a Web Worker in hyperscript and call its methods like a normal object
worker Calculator
def add(a, b)
return a + b
end
end
WebSocket Listenerhyperscriptrealtime
Open a WebSocket and route incoming messages into the DOM
socket ChatSocket ws://localhost:8080
on message
put it into #chat
end
When Any Of Several Values Changebothreactivity
Watch multiple expressions; body fires when any one of them changes
when $firstName or $lastName changes put `${$firstName} ${$lastName}` into #full-name end
When Computed Value Changesbothreactivity
React to changes in a computed expression; `it` is the new value
when (#price's value * #qty's value) changes put "$" + it into me end
Window Keydown Handlerbothwindow-events
Handle Ctrl+S globally
on keydown[key=="s"] from window if event.ctrlKey halt call saveDocument() end