Agent-readable docs index: /effect-swiftui/llms.txt. Full docs in one file: /effect-swiftui/llms-full.txt. Download /effect-swiftui/docs.zip to grep all markdown files locally.

AppKit 0.2.x: Native workspace views

AppKit 0.2.x archive. Use an AppKit checkout for this example. For current controls, see the SwiftUI overview.
From the repository checkout, bun run demo:desktop opens the travel notebook using only built-in views. Select a section, choose a document, then press Show checklist in the toolbar (or ⌘2). Check a task, navigate away and return: the notebook model, not a Swift shell, owns the checkmark. bun run demo:workspace opens the original custom SwiftUI rendering shown in the recording.

Layout, appearance and images

Make h.desktop the sole top-level element to fill the surface, including when the window resizes. Other top-level views retain the original centered layout. Built-in views accept size: { width?, height?, minWidth?, minHeight? } in nonnegative points. Omit a size constraint to let AppKit choose. Layouts accept renderer-managed children, including components and registered leaves. Use h.label for text outside stack and row.
BuilderNative behavior
stack, rowNSStackView; spacing (default 8), equal-edge padding, cross-axis alignment: leading, center, trailing or fill. For a row, leading/trailing on its cross-axis mean top/bottom.
gridNSGridView; positive integer columns (default 2), spacing. Children flow row by row in renderer order.
splitDraggable NSSplitView panes, arranged side-by-side for axis: "horizontal" (default), top/bottom for "vertical". Set minimum pane sizes on the children.
scrollVertical NSScrollView; the document stack fits the viewport width. on("scroll", ({x, y}) => …) observes clip bounds in points. For large homogeneous data, use the collections below instead.
materialNSVisualEffectView, with material of sidebar, content, header, or popover. The system resolves appearance and accessibility settings.
imageNSImageView. source takes one SF Symbol symbol or local fileURL, plus a description for accessibility. No remote fetch.
labeltextStyle: { font?, color?, wrap? }; fonts body, headline, title, caption, monospaced; adaptive colors label, secondary, accent, red.

Selection without building a view for every row

h.table .prop("columns", [{ id: "title", title: "Document" }, { id: "place", title: "Place", width: 120 }]) .prop("rows", [{ id: "journal", title: "Postcards", cells: { place: "Naples" } }]) .prop("selection", model.documentID) .on("select", id => Message.Select({ id }))
list is a headerless single-column NSTableView; table displays named columns. outline uses NSOutlineView and accepts recursive children arrays on rows. Each row needs a unique, stable string id across the entire collection and a title. A cell uses cells[column.id] if provided; otherwise the title column (or first column) uses title. AppKit recycles offscreen cells; the row data crosses the bridge as a snapshot, not a streamed or paged data provider. Reuse a rows array while the data has not changed.
select sends a row ID, or null on deselection. Omit selection for native ownership, or supply a string or null to keep selection controlled. An ignored change restores the model selection. Reordering rows does not change their identity; an outline remembers keyed branches' expansion. Selecting a nested item opens its ancestors. Duplicate row/column IDs are errors.
An action is { id, title, symbol?, key? }. Handle on("action", id => …) to receive its ID, not its display label. Key equivalents are local to the key window, not system hotkeys. Prefer a single desktop per window.
BuilderContract
desktoptitle, toolbar (NSToolbar actions), commands (key window's Commands menu), contextMenu (native context menu at the desktop), and windowAction: { id, action: "minimize" | "zoom" | "close" }. Supply a fresh request ID for each intentional action. Window creation belongs to the embedder; removing the desktop restores its previous chrome.
menuButtonNative pull-down button, title plus items (actions).
navigationpage is a zero-based index into the ordered children. The inactive native pages detach but keep their state. Set page from model state to implement Back/Forward; this does not create global navigation history.
popover, sheettitle labels a native trigger button. The children become the content of a transient NSPopover or document-modal sheet. Escape or Done dismisses; dismiss carries null. Focus returns to the prior responder if it still belongs to the presenting window.
alerttitle labels the trigger, message and detail describe the alert, and items describe the buttons in order. Respond to action for the choice the user actually made.

Native input, not DOM bubbling

inputArea marks a specific region (give it a size or children). Set label for accessibility. Its background and passive labels/images receive pointer events; embedded controls retain their normal click and key handling. An area listening for key accepts first responder on click. No application-wide monitor or cancellable DOM event is installed.
  • hover: boolean on enter/exit of its tracking area in the key window.
  • pointer: { phase: "down" | "up" | "move" | "drag", x, y, button, clicks, shift, command, control, option }, for primary-button interactions and pointer motion. Coordinates are local points measured from the top-left.
  • key: { phase: "down" | "up", characters, code, repeat, shift, command, control, option }. Menu shortcuts and AppKit key traversal retain their native meanings. Use editable controls for text/IME input.
  • resize: { width, height } in points; successive frame changes during layout are coalesced.
  • drop: { files: string[], text: string | null } for a copy from the dragging pasteboard. files contains file URL strings, not bytes, persistent permissions or security-scoped bookmarks. Set dragText to start native text drags from this region.
The TypeScript entry composes the split view, toolbar, library list, document table, reader, checklist, menus, presentations and note drop target. The same notebook model also runs the separately registered SwiftUI example.