This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.

Time, motion, and geometry

A task schedules one action, with no arguments:
contract
component Clock
state ticks = 0
action tick
ticks = ticks + 1
task ticker mount
every(1000, tick)
view
text `${ticks}` testId="ticks"
every(ms, action) first fires one interval after its instance mounts, and after(ms, action) fires once, ms after that mount. Intervals are whole-number literals of at least 1. every(frame, action) runs once per presented frame without catching up missed frames. Each task body contains one schedule. A child at a bounded use owns the same forms for its instance's lifetime; each firing runs in that instance's frame. A task is a schedule, not a lifecycle hook. A hidden instance stays alive, so use when active to stop its task while hidden. Each active every(frame, …) runs once per frame per instance.
A task can wait for state instead of starting at mount:
contract
component Undo
state toast = ""
state toastUntil = 0
action deleted
toast = "Deleted"
toastUntil = performanceNow() + 5000
action hideToast
toast = ""
task hide when toast != "" key=toastUntil
after(5000, hideToast)
view
text toast testId="toast"
The timer exists while toast != "" holds, as an if arm's nodes do, and a new toastUntil restarts it, as a new key makes a new for row: a replaced toast gets its whole five seconds. Nothing runs when the gate changes, and an idle task keeps no host awake. The action runs at the deadline exactly, so it clears the toast without testing the time again. Gates and keys read state, never performanceNow() (LLP 1092).
performanceNow() reads milliseconds since this launch of the app on the runner's clock (it restarts at 0 on every launch; the driver's clock under the agent); it is not a date, and anything stored or sent takes time.epochAtZero + performanceNow() instead. For the date, read the reserved exactTime source and add time.epochAtZero + performanceNow(). There is no now(); the compiler refuses it and names both. Advancing the clock alone does not necessarily trigger rendering: a derive using performanceNow() reevaluates when a later commit evaluates it. Use a task when the display must tick.
Use CSS transition for changes to supported properties and keyframes with animation for authored motion:
contract
keyframes breathe
from opacity=0.4
50% opacity=1
to opacity=0.4
component Motion
state open = false
action toggle
open = not open
view
column gap=12
button press=toggle testId="toggle"
text "Toggle"
column opacity=(open ? 1 : 0.4) transition="opacity 200ms ease" height=40
text "Working" animation="breathe 1.6s ease-in-out infinite"
Keyframe values are evaluated at compilation using the runtime's pure operations: list literals, .at(), option match, templates and pure built-ins, including toFixed and formatDecimal. Only executed branches are evaluated. Reading state, resources, props, the clock, the locale or a host capability is refused by name. Keyframes animate paint and transform properties, not layout ones such as width. Styles remain literal-only. CSS easing and the admitted -exact-spring(…) timing function, which belongs only inside transition, are not interchangeable guesses: copy the appropriate motion fixture. In a list virtualized=true row, an animation waits until its row first shows in the list (-exact-animation-trigger="view", the default), because the list builds rows before they scroll in; -exact-animation-trigger="none" starts it when the row is built, so the row arrives settled. Revealing a row preserves an authored animation-play-state="paused". A row that stays mounted plays only once; retiring and mounting it again starts a new play.
-exact-exit-animation, -exact-layout-transition, and presentation timelines (-exact-drag-timeline, animation-timeline, animation-range, timeline-scope) are declared extensions with bounded behavior, not arbitrary layout animation.
A value that follows a scroll is CSS's scroll-driven animation, not a scroll action that writes state (one round trip behind the scroll). scroll-timeline on a scroller names its offset; view-timeline on any node names that node crossing its nearest scroller; animation-timeline names either, or is scroll() or view(), and animation-range takes lengths, percentages and the view ranges (cover, contain, entry, exit, entry-crossing, exit-crossing). Every host moves the consumer in the scroll's own frame, and the web leaves it to the browser (agents' guide).
For direct manipulation, pan, panrelease, heightrelease, transformgeometry/transformrelease, and reorderdrop supply measured payloads. The transform pair must be declared together. The height, transform and reorder drags start only from a handle that names its target's id with heightDragFor, transformDragFor or reorderFor, and reorderdrop belongs to a vertical list virtualized=true, whose rows are the only ones a host can drag. The platform owns gesture recognition and competition with scrolling; Contract does not define a general gesture arena. A heightDragFor handle names its unique strict ancestor by id. The target needs box-sizing="border-box" and a finite nonnegative point height (such as height=200). A percentage, auto or an omitted height cannot bind. The handle and its ancestors must be displayed, enabled and non-inert. The compiler warns with lower-height-drag-ineligible when it can prove a requirement fails; computed values remain runtime checks. See Interaction Gallery and Spark for complete bindings.
frame("id") reads the last laid-out border box where the viewer sees it, as getBoundingClientRect does: in the viewport, every scroll offset above it applied (the page's too), and every transform, its own and its ancestors'. measure("id") asks for its height-auto layout, at the same origin, under its current offer; its id is literal. Both are action-only and return Geometry, including unavailable and provisional; handle those flags rather than assuming layout already happened. Geometry reads are not reactive view expressions.
Is this helpful
Last updated November 30, 2026
Exact Docs