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.

Built-in controls and custom SwiftUI views

Use a built-in when the TypeScript component only needs to describe a control’s value and handle its events. Register a SwiftUI view when your app needs platform-specific layout or a control outside the vocabulary. You don’t need to change the renderer to add a picker.

Built-ins in 0.3.0

BuilderWhat you supplyWhat comes back
h.stack, h.rowChild views with .children(...)No event
h.labelvalue (text)No event
h.buttontitle; optional focus and keyboard shortcutpress
h.checkboxtitle and checked; optional focus and keyboard shortcutchange with a boolean
h.sliderNumeric value; optional accessibilityLabel and focuschange with a number
For a checkbox, emit a message on change and read checked from the model on the next render. The model can reject the change; the control should then show the old value. Text fields with controlled selection and IME composition are not built-ins in this release. See the counter for a working checkbox, slider and keyboard shortcut together.

Register a picker

In the preset example, the model owns step. TypeScript gives the native view a name and a small JSON contract: a selected number goes in; a chosen number comes out.
const PresetPicker = defineNativeView<{ selected: number }, { step: number }>("PresetPicker") // Inside the component's view: PresetPicker({ selected: model.step }, event => Message.Choose(event))
On the Swift side, register the same name with NativeViewRegistration. Decode the props, bind a SwiftUI Picker to props.selected, and call emit(PresetEvent(step: newValue)) when the user chooses a segment. Pass that registration in EffectSwiftUISurface(script:registrations:). There’s no second stored step value in Swift. See the complete Swift registration.
Original preset demo with 1, 5 and 10 segments alongside the count and visibility controls
From the archived AppKit docs: the segmented picker itself was already a SwiftUI view. The old host wrapped it; the current registration returns the SwiftUI view directly.
From the 0.3.0 checkout, run bun run demo:presets. Select 5, press the count button, then hide and show the picker. The count advances by five, and the selection survives because it belongs to the model.

When the view needs children

A picker is a leaf. The iPhone notebook is a container: Swift supplies a scroll view and bottom bar while Effect supplies the task rows. Pair defineNativeContainer in the pocket component with NativeViewRegistration(name:container:) in the app. Render the provided child views rather than creating another set of task rows in Swift.