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.
Declarations
ebnf
file = { declaration } ;
declaration = use | shape | enum-decl | function | source | style | decoration | atom | keyframes
| font | sound | theme | timeline | color-profile | routes | component
| members-block | test ;
use = "use" use-name { "," use-name } "from" STRING NL ;
use-name = IDENT [ "as" IDENT ] ;
shape = "shape" IDENT block(field) ;
enum-decl = "enum" IDENT block(STRING NL) ;
field = FIELD ":" type NL ;
function = "fn" IDENT "(" [ typed-params ] ")" ":" type "="
( expr NL | NL INDENT expr NL DEDENT ) ;
typed-params = typed-param { "," typed-param } [ "," ] ;
typed-param = IDENT ":" type ;
source = "source" IDENT "(" [ typed-params ] ")" "as" "shape" type
block(source-line) ; (* the root file's; LLP 1162.001 *)
source-line = ( "url" STRING | "method" STRING | "header" STRING STRING
| "body" "json" | "graphql" STRING | "pointer" STRING ) NL ;
style = "style" IDENT block(style-line | part) ;
decoration = "decoration" IDENT ( style-line | block(style-line) ) ;
atom = "atom" IDENT style-line [ block(style-line | state) ] ;
style-line = { FIELD "=" style-literal } NL ;
part = "::" ( "placeholder" | "backdrop" | "view-transition-new"
| "view-transition-old" ) NL block(style-line) ;
style-literal = STRING | NUMBER | "-" NUMBER | "true" | "false" ;
keyframes = "keyframes" IDENT block(keyframe-line) ;
keyframe-line = selector { "," selector } { FIELD "=" frame-value } NL ;
selector = "from" | "to" | NUMBER "%" ;
frame-value = STRING | NUMBER | "-" NUMBER | constant-call ;
constant-call = IDENT "(" [ arguments ] ")" ;
theme = "theme" block(IDENT "=" STRING NL) ; (* the root file's; LLP 1095 D4 *)
timeline = "timeline" IDENT NL ; (* a clock timeline `animation-timeline` names *)
color-profile = "color-profile" "--" IDENT style-line ; (* CSS's @color-profile: --brand src="…" *)
font = "font" STRING ( "=" STRING NL | block(font-face) ) ;
font-face = NUMBER [ NUMBER ] [ "italic" ] "=" STRING NL ; (* a weight, or a variable face's range *)
sound = "sound" STRING NL ;
routes = "routes" IDENT { attribute } block(route-row) ;
route-row = [ "tab" ] IDENT STRING { attribute } NL [ route-children ]
| "notfound" { attribute } NL ;
route-children = INDENT route-row { route-row } DEDENT ;
routes and its rows accept optional bare-word external-entry policy attributes
(external=link or external=none, default link; fallback=<route> naming a
parameterless external=link route in the same table; LLP 1038 D2/D8). External
entries (universal links, App Links, custom schemes, push taps, shortcuts,
external launch URLs) targeting an external=none route are refused or
redirected to fallback= once in the router, while normal app launch and
internal navigation are unaffected. Route admission reduces blast radius and is
not an authorization boundary; sensitive screens must still authorize actions in
place.
A source is one HTTP request the runner makes for a resource or a send
of its name (Declared sources): url
is required, each other line at most once but header, and graphql takes no
method or body beside it. A call passes the declared parameters and
declares the same shape (type-source-declared).
A font face's weight is a whole number in 1–1000. Keyframe percentages are in
0–100; from and to are 0% and 100%. Lowering checks whether keyframe properties
are animatable and constant-call values can be evaluated at compilation.
Constant calls use the runtime's pure operations: list literals, .at(), option
match expressions, templates and pure built-ins such as toFixed and
formatDecimal. Only executed branches are evaluated. Reading
state, resources, props, the clock, the locale or a host capability is refused
by name; evaluation and expansion limits produce compile errors.
Styles accept literal style attributes and explicitly styleable props (currently
backgroundMaterial, glassGroup and buttonStyle), not arbitrary expressions
or event props. In a conditional class, each prop must be set in both styles or
neither, unless the node supplies its own value. Each arm's literal is checked
as a direct attribute would be.
A part is CSS's pseudo-element as a block: ::placeholder, ::backdrop,
::view-transition-new or ::view-transition-old, then its declarations
indented beneath it, in a style (literal) or under its element before its
children (where a value may compute, as the element's own attributes do).
::placeholder, under an input or textarea, admits color alone (CSS
::placeholder { color }, LLP 1104 D3); ::backdrop, under a dialog, admits
background-color alone (CSS ::backdrop { background-color }, LLP 1035.001
D11: what lies over the page beneath the modal dialog, fading in and out with
it). Each colour's alpha is its own; the element's own block wins over its
class's, and without one the platform's colour or dim stays. Another property
in either is lower-unknown-attr; on another element lower-attr-tag.
On a route (an element with navigationKey), ::view-transition-new is its
entrance, when a push or a full-screen presentation adds it, and
::view-transition-old its exit, when a pop or the dismissal removes it (CSS
View Transitions' pseudo-elements, LLP 1013.001 D1). Each admits the
animation shorthand alone, naming keyframes that move only opacity,
translate, scale and rotate; it must end (not infinite or paused),
and each arm of a computed value is a literal. none cuts, and a part left
unset keeps the platform's transition. A sheet's route, a route with a literal
navigationSource, and an element that is no route refuse them
(lower-route-part); the other ::view-transition-* parts have nothing to
style.
::before and ::after are syntax-part (Contract has no generated box:
write a child), as is any other part. placeholder-color and
-exact-placeholder-color are refused with the block to write.
A state part is a block of one state's rows (LLP 1121 D8): :active, :hover,
:focus-visible, :disabled or :checked alone on its line, then rows indented
beneath it, in a style (literal) or under a node before its children (where a
value may compute). One state a block, once at a place, never nested and never
combined (syntax-state). :disabled and :checked (when checked,
aria-checked, aria-selected or aria-pressed is true) take
background-color, color, border-color (each side), opacity, box-shadow
and -exact-tint-color, and fold into the node's own rows, :checked under
:disabled; :active takes background-color, color, opacity, translate and
-exact-press-scale and lowers to the press paint (LLP 1061 D7: its opacity an
absolute target, its translate a 2D offset added to the node’s own translation
without changing layout; the web hit area moves with the paint, while native
hosts keep the unpressed hit area). :hover and :focus-visible
take background-color, color, border-color, opacity, box-shadow and scale (which stands in for the
node's and moves on its transition). Active targets may compute or clear
with none; hover and focus targets are literals (lower-state-literal; a
token's name is one). Another row is lower-state-row;
native buttons and list rows accept :active and keep their other native states.
A host rejects properties its projected native component cannot express, names
them in the journal and keeps the native component.
A part on another native control, or (for :active, :hover and
:focus-visible) a run inside a paragraph is lower-state-target. An :active
row beside the same paint's -exact-press- row is lower-state-press-paint.
The node's block wins over its class's, row by row.
A width media block (@media, LLP 1048.003 D3) overrides static style rows at
breakpoints of the viewport's width (the window's, as exactViewport().width), inside a style declaration or under a view
element before its children (never nested, and never inside a :state part):
@media (min-width: 900px), @media (max-width: 899px), @media (min-width: 600px) and (max-width: 1199px),
or Media Queries Level 4 ranges (@media (width >= 900px), @media (600px <= width < 1200px)).
Widths are non-negative px (or unitless 0). Only literal style rows (theme
tokens and unset included) are admitted; a non-style attribute, a computed
value, or a @media row that collides with a computed base binding for the same
style property is refused (lower-media-dynamic). Matching blocks compose in
source order (class= before the node's own), over static base rows and under
:hover, :focus-visible, and :active. On the web JS target they emit
static @media CSS rules with zero hydration flash; native hosts re-evaluate
them when the viewport crosses a breakpoint.
A length attribute's string is CSS's own text, read by the kernel: a px or
other absolute length, a percentage, a viewport length, auto,
env(safe-area-inset-*), env(viewport-segment-* x y),
env(titlebar-area-x|y|width|height), a layout region's
env(-exact-<region>-inset-*), the safe area where the box is,
var(--exact-safe-area-inset-*) (LLP 1123 D9), or a calc(), min(), max()
or clamp() of these (clamp(15px, env(safe-area-inset-bottom), 60px); LLP
1001 §2). Anything else is lower-attr-value, with the kernel's reason.
Viewport lengths are quoted CSS strings (width="100vw"), not Contract numbers.
The ten supported spellings are vw, vh, vmin, vmax, svw, svh,
lvw, lvh, dvw and dvh. Logical-axis units (vi, vb, svi, svb,
lvi, lvb, dvi, dvb) and the s/l/d forms of vmin/vmax are
unsupported. See the guide's viewport and container
units for which rows
take them, web/native behaviour and sheets;
contract vocab viewport-and-container-units (or viewport-units, vw, cqw, …)
answers at the command line.
The layout regions (LLP 1123 D10) are the platform's own spacing, measured from
the layout viewport, inside the safe area by default: layout-margins (UIKit's
16 or 20 points), readable-content (a comfortable reading width), and
safe-area-corners, layout-margins-corners and readable-content-corners,
the same kept clear of rounded corners. padding-left="env(-exact-layout-margins-inset-left)"
puts a header where a UIKit screen's would be. On a host without them (the web,
Linux, Windows) each is the safe area.
The title-bar area is
Window Controls Overlay's: the part
of the title bar beside the window's controls. On the Mac, under viewport-fit="cover",
it is AppKit's title bar less the traffic lights and their margins (78 0 822×32 in a
900-point window with a left-to-right title bar, 0 0 822×32 with a right-to-left one);
all zero in full screen and while the session's toolbar fills the title bar. Once
navigation history retains a toolbar, it stays (LLP 1115.000, retention as built).
In a single-location app, a root header can bring a toolbar before history retains
one; it goes away when that header hides or its route says navigationBar="none".
With no stack, or before any route has shown a bar while every mounted route says
navigationBar="none", navigation brings no toolbar. An authored toolbar or sidebar
can still supply one.
If the manifest's
display_override puts window-controls-overlay first, a window with no toolbar of
the session's own gets the platform's tall title row: an empty unified toolbar over
the page, whatever its viewport-fit. The area is that row beside the traffic lights,
and exactViewport().displayMode is window-controls-overlay.
With viewport-fit="cover" and no toolbar, AppKit reserves part of the title bar for
dragging the window. It excludes visible, enabled native controls that accept first
responder, such as a standard button. A painted pressable can lie inside the drag
region even with app-region="no-drag". The Mac agent sends tap inside the app.
A reply with windowDrag=true means a mouse press at that point may move the window
even though the agent ran the action. Use the overlay for a title row with custom
pressables. Its controls receive clicks and its empty ground keeps the system's
window drag and double click.
On Windows, the manifest can enable the overlay if the first plan loaded into
the window declares an app region. The app extends into the title bar beside the native caption buttons.
Windows reports the overlay display mode after the native window negotiates it,
before the first frame. Mark ground that moves the window with
app-region="drag". A nested control can take input with
app-region="no-drag". The closest declaration wins. Keep a usable drag area
on every screen that shows the overlay.
Chrome gives the same environment names to an installed app. When the area is
undefined, as in a browser tab, env(titlebar-area-height, 0px) takes its
fallback, and without one the row takes its initial value.
-exact-fit="shrink" on a text (CSS has no such property; LLP 1116.001 D1.4) draws
a line too wide for its content box at the scale that fits: its whole line under
white-space="nowrap", else its longest word. It shrinks down to half its size, and
a display size (more than twice the root font size) down to the root size; below that
it overflows, as UIKit's adjustsFontSizeToFitWidth truncates. The kernel picks the
scale and every host draws at it; "none", the default, never shrinks.
A sound names a WAV under the app's assets/ (LLP 1096 D1): 16-bit integer
or 32-bit float PCM (or WAVE_FORMAT_EXTENSIBLE naming one), one or two
channels, 8–96 kHz, at most 10 s. The compiler reads its header and refuses
anything else with the file named and the conversion to run
(lower-sound-format, lower-sound-long, lower-sound-path,
lower-sound-unreadable). sound is a word only at the start of a top-level
line, so a state sound is a slot. Sounds are app-wide, as fonts are.
A use specifier is a relative path (./ or ../) to a .contract file that
stays inside the using file's root — the app directory, or the package it
belongs to (contract-use-path); an exact: built-in (exact:motion, exact:content;
contract-use-builtin); or a package name, name[/sub] or
@scope/name[/sub], found in the nearest node_modules above the using file
and mapped through its package.json exports (a string, or the contract or
default condition), else index.contract (contract-use-package). A package
outside the app needs a name in its package.json (contract-package-unnamed):
its components' identities are named by it (LLP 1121 D15). A root file linked
into the app's tree from elsewhere (a symlink, as conform's corpus fixtures are)
that is in no named package is the app's own, named where the link sits (one in
a named package keeps the package's name); a file a use reaches is its
target's.
contract sources <file> prints every file a compile reads, as JSON. A file's
names are its own declarations and the names its use lines list, each
optionally renamed with as (LLP 1091): a component, shape, function, style,
keyframes, or timeline, declared by the used file or named by its own use
lines. A name another file declares and this one does not name is refused
(contract-use-missing): one refusal a file, naming every use line the file
lacks — the line it has for that file, extended, or a new one — and contract fmt --uses <root.contract> writes them (bun exact.mjs update does too, for an
app outside this repo). A name two files declare, or one the compiler gave on a
collision (Card__ui), is left to the author and said. The keyframes an animation, animation-name or
-exact-exit-animation literal names, and a -exact-clock(Name) literal, resolve in the
file that writes them; a name computed at run time is matched as written. Beside
a computed value, a word is renamed when it is the name whatever the value is;
one that is the name for some values and a keyword for others (${x} linear 1s), when it is also keyframes another file's of its name renamed, is refused
(contract-animation-ambiguous): quote the name ('linear').
A package's export may be its module declaration, exact.json (LLP 1133.001
D1): use getCurrentPosition, GeolocationPosition from "@exact/geolocation"
brings the module's sources and sends and its shapes. A module's source is read
by a resource and its send by a send, each as shape what it answers
(contract-module-kind, contract-module-answers), with keyword arguments
only: the module's options (maximumAge=600000), each omitted one left to the
platform, and each platform's words as dotted keywords
(apple.desiredAccuracy="threeKilometers"), checked against the words that
platform's implementation declares (contract-module-positional,
contract-module-argument, call-argument-twice). The device answers it, never
the build: its placeholder is else empty() (contract-module-placeholder).
A send that answers nothing ("answers": null, LLP 1133.004 D5) is a statement
in an action, as a host command is (showNotification(title="Done", tag=t),
from @exact/notifications: notifications);
a send to one is refused (contract-module-answers), and so is a statement
calling a send that answers something (contract-module-kind). A module's
event (D6) is heard with an attribute on the root component's outermost node,
column notificationclick=opened, naming an action of the root that takes a
prefix of the event's arguments (an untyped parameter takes the event's type;
contract-event-handler); anywhere else, or a second time, it is refused
(contract-event-root). Each event is delivered once, in order, as its own
commit; a host raises one only once the app has drawn its first frame, so one
that starts the app is held until then.
Fonts are app-wide. A used file cannot declare routes. The root file's first
component remains the root. A name both declared and used
(contract-use-shadows), one name used from two declarations
(contract-use-duplicate), and cycles are refused.
A route pattern is an absolute path with literal or whole :name segments.
Indentation determines its parent. The optional fallback is notfound without
a path; with none, the compiler writes it and its screen (a navigation root drawing for e in stack(nav)). Route policy fields use attribute syntax and are validated by the
route/document compiler.
Is this helpful
Last updated November 30, 2026