The page
Widgets
The page
widgets.md

Widgets

Examplea whole program
state src = "let n = 1\n"
state saved = ""
action save(text: string)
saved = text
column gap=8 padding=16
editor value=src lang="js" change=save height=300
text `${src.length} characters; ${saved.length} saved` color=dim

Mental model#

The built-in elements, and where each is documented#

editor#

richtext#

Examplea whole program
state doc: json = richtext.from("Hello Ada,")
state sent = ""
action send
sent = richtext.html(doc)
column gap=8 padding=16
richtext value=doc placeholder="Write…" aria-label="Message" height=240
button "Send" press=send
text sent color=dim

terminal#

Examplea whole program
state out = "Welcome\r\n$ "
state grid = ""
action typed(data: string)
out += data
action sized(s: string)
grid = s
column gap=8 padding=16
terminal output=out input=typed change=sized height=320
text grid color=dim

flow#

Examplea whole program
shape Step
id: string
x: number
y: number
title: string
shape Wire
id: string
from: string
to: string
state nodes: Step[] = [{id: "a", x: 0, y: 0, title: "Start"}, {id: "b", x: 320, y: 80, title: "End"}]
state edges: Wire[] = [{id: "e1", from: "a", to: "b"}]
state locked = false
action changed(e: string)
let ev: json = JSON.parse(e)
if ev.type == "move"
for m in ev.nodes
let hit = nodes.find(s => s.id == m.id)
if hit
hit.x = m.x
hit.y = m.y
flow edges=edges locked=locked change=changed height=400
for s in nodes key=s.id
view id=s.id data-x=s.x data-y=s.y padding=12 background=card border-radius=8
text s.title
view data-panel="top-right"
button (locked ? "Unlock" : "Lock") press={locked = !locked}

chart#

Examplea whole program
state rows: json = [{x: 1, y: 3}, {x: 2, y: 5}, {x: 3, y: 4}]
state seen = ""
action heard(e: string)
let ev: json = JSON.parse(e)
seen = ev.type
column gap=8 padding=16
chart data=rows marks=[{kind: "line", y: "y", label: "y"}] x=({col: "x", type: "linear"}) label="A line" change=heard height=200
text seen

Pitfalls#

Where a new element goes#

In the source#

esc
1072 sections of 111 pages, ranked as you type.A heading's words count for more than what stands under it.
↑↓move
↵open
ranked by BM25, in the page