Presentation reference
Pages and styling
A browser component can declare a semantic page tree alongside its verified actions and views. The compiler emits static HTML and CSS for the initial document. Its shared adapter connects the rendered controls to the Wasm exports.
Write a page tree
page "Approve once and inspect the resulting state."
main id content
h1 "Approval latch"
p "Approved (0 or 1)"
read status "0" label "Approved"
press approve
a "Back to the heading" href "#content"
endAdd at most one page to a component owned by browser. The quoted description becomes the document’s meta description. The component title becomes the HTML title. Each line creates an element. Start top-level elements two spaces in. Indent a child by two more spaces than its parent and return to a smaller indent for a sibling or ancestor. Close the block with end at the left margin.
Text is optional and immediately follows the element name or binding. The compiler escapes text and attributes. Text followed by nested elements appears before its children. For longer code examples use a pre node with a code child and a JSON string containing escaped newlines.
pre
code "set reviewing = 0\nset sealed = 1"- Structure
- header, nav, main, section, article, aside, footer, figure, figcaption, div
- Text and inline content
- h1, h2, h3, p, span, a, strong, em, small, pre, code, output
- Lists and definitions
- ul, li, dl, dt, dd
- Wasm bindings
- press, read, message. Each requires the unquoted name of an existing action, view, or observer respectively.
Bind a page to a verified component
- press ACTION ["CAPTION"]
- Emits a button for a no-argument action. Omitting the caption uses the action label. It starts disabled in the HTML. The adapter updates its disabled property from the corresponding guard and dispatches the Wasm export on click.
- read VIEW ["PLACEHOLDER"]
- Emits an output node. After initialization and on each render, the adapter writes the view’s numeric value as decimal text.
- message PEER ["PLACEHOLDER"]
- Emits an owner-side output for the latest present message to that peer. An absent slot leaves the last displayed value intact. Add a when binding if that old value should be hidden in another phase.
- when VIEW
- A modifier on an element that binds visibility to a u1 view. The HTML initially marks it hidden. Rendering updates the hidden property from the current view. A numeric view wider than one bit is rejected.
view sealed_status "Shares prepared" = sealed
# Inside a page, nested under a parent
press share "Confirm and split"
message north "—" when sealed_status label "North share"A page button cannot collect an action payload. The generic interactive host generated at serve time for a component without a page can display a numeric input. For a custom page, bind no-argument actions or implement the typed-input control at the host boundary. The static page adapter displays outbox messages locally.
Attributes and links
- class "NAME ..."
- Assign one or more CSS classes as a string, for example class "button primary".
- id NAME
- Assign an unquoted identifier unique within the page. Same-page #fragment links must name a declared id or the build fails.
- href "URL"
- Use on an anchor. Paths, fragments, and https:// URLs are supported. Protocol-relative URLs, other schemes, whitespace, and backslashes are rejected. Cross-page link targets are resolved by the host.
- label "TEXT"
- Set aria-label on the generated element. Supply a useful accessible name for a control or navigation landmark.
- when VIEW
- Use alongside class, id, label, and, on anchors, href. The name must resolve to a one-bit view.
Place text first, then modifiers on the same physical line. Semantic structure, focus, accessible naming, contrast, and usable mobile hit targets still require browser testing.
Style a page at different widths
style ".controls"
display "flex"
gap ".75rem"
end
style ".controls" below 640
flex_direction "column"
endA style block takes a quoted CSS selector and a series of property-name and quoted-value pairs. Use underscores for hyphens in property names, for example background_color. The compiler emits these declarations in source order. An optional below N produces an inclusive max-width media query in pixels. N must be an integer from 1 to 8192.
Selectors must be nonempty and exclude braces, semicolon, @, <, backslash, and slash. Values exclude braces, semicolon, angle brackets, and line breaks. The browser interprets CSS values. Styles require a page in the same component.
Build and serve a custom page
bin/weft build latch.weft -o build/latch
bin/weft check latch.weft -o build/latch
bin/weft serve latch.weft -o build/latch --port 8080Serve from the extracted compiler directory so the browser support files are available. A static deployment ships index.html, style.css, weft.mjs, app.wasm, and interface.json in the same directory. verification.json and the original source let a reader inspect and recheck the build.
The checker regenerates the HTML, CSS, and shared adapter from source and compares them byte for byte with the saved files. The formal proofs establish the component’s values and transitions. CSS interpretation, JavaScript execution, accessibility-tree behavior, and network transport belong to the trusted environment.
Read the complete source for this manual page