The field guide
Build with Refract.
From your first view to the graph underneath it.
A practical guide to building interfaces with Refract.
Your first Refract application.
Set up the toolchain and run a shared Rust view in the browser or on native.
Fundamentals
Views
Compose typed views and preserve their mounted identities.
Layout & Style
Build layouts with stacks, then make them yours with composable modifiers.
Reactivity
Read and update reactive state, and share values throughout the view tree.
Input & Focus
Handle input, bind focus to state, and style focused controls and containers on web and native.
Effects
Tie external work to mounted lifetimes with explicit dependencies and cleanup.
Channels
Deliver async and background results to reactive state on web and native.
Animation
Animate state changes and view transitions with shared timing on desktop and web.
Canvas
Build portable vector illustrations with shapes, paths, reactive canvas inputs, and animation.
Shaders
Render application-owned WGSL with reactive uniforms, image inputs, and animation on native GPUs and WebGPU.
Macros
Declare views, state, actions, effects, and environment reads with Refract’s authoring attributes.
Reference
Overview
Choose a primitive, layout helper, or drawing API, then configure its view-specific and shared modifiers.
View Modifiers
Configure views with shared modifiers and concrete canvas, shader, shape, text, and image methods.
Browser & Native
Mount or prerender a browser app, pass reactive inputs from its host, run shared views in a native window, and read the host surface.
Primitives
view
Create a basic box for styling, semantics, or interaction.
text
Display a string with typography, wrapping, and semantic labels.
image
Display an image from a URL, file path, or embedded asset.
field
Edit a single-line or multiline string through a binding.
fragment
Group a sequence of views without adding a host element.
Layout
stack
Arrange children with a configurable horizontal or vertical direction.
h_stack
Arrange children horizontally with spacing and alignment.
v_stack
Arrange children vertically with spacing and alignment.
z_stack
Layer children in shared bounds.
spacer
Consume remaining space inside a row or column.
scroll_view
Place content in a viewport with initial positioning, following, and scroll observation.
Composition
Internals
Architecture
How the reactive graph, mounted view tree, and platform hosts turn shared Rust views into incremental UI updates.
Internal Types
How typed builders, View, Element, and the mounted runtime fit together.
Graph
How Refract tracks dependencies and turns a state change into a host update.
Native Rendering
How the native host turns retained elements into layout, drawing commands, and incrementally rendered pixels.
Text Editing
How core and the platform hosts synchronize text, selection, formatting, and composition in retained editors.
Surface
How host observations and ordered requests use the attribute graph without adding a separate reactive runtime.
Async Work
How background results enter the UI thread, propagate through the graph, and follow mounted lifetimes.
For Agents
These guides describe the current implementation. Refract is early software, and its APIs are still evolving. The architecture guide explains the crate boundaries and current limitations.