Roact is a declarative UI library for Roblox Lua, closely modeled on Facebook’s React. Instead of manually creating, parenting, and mutating RobloxDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Roblox/roact/llms.txt
Use this file to discover all available pages before exploring further.
Instance objects, you describe what your UI should look like using lightweight element trees — and Roact takes care of creating, updating, and destroying the underlying Instances to match. This separation of description from implementation makes complex, dynamic interfaces far easier to reason about, test, and maintain.
How Roact works
In traditional Roblox UI code, you imperatively callInstance.new, set properties, set Parent, and track every change yourself. Roact flips this model: you write a function or component that returns an element tree, Roact reconciles that tree against the current state of the game, and only the parts that changed are touched. This is the same virtual-DOM approach React popularised for the web, adapted for Roblox’s Instance hierarchy.
Key concepts
Elements
An element is a plain Lua table that describes an Instance or component — its class, properties, and children. Elements are cheap to create and never touch the DOM directly.
Components
Components are reusable building blocks. Roact supports function components for simple, stateless UI and stateful components (extending
Roact.Component) for UI that needs lifecycle methods and internal state.State & Lifecycle
Stateful components can hold internal state and respond to lifecycle events such as
didMount, didUpdate, and willUnmount, giving you full control over how your UI initialises and cleans up.Events & Bindings
Roact provides
Roact.Event and Roact.Change prop markers for connecting to Roblox Instance events and property-changed signals. Roact.createBinding gives you reactive values that update Instance properties without a full reconcile.Full API surface
Roact exposes a focused, stable public API that maps closely to React’s:| API | Purpose |
|---|---|
Roact.createElement | Create a virtual element describing a Roblox Instance or component |
Roact.createFragment | Group multiple elements without an extra parent Instance |
Roact.Component | Base class for stateful components |
Roact.PureComponent | Stateful component with shallow-equality shouldUpdate |
Roact.mount / unmount / update | Mount, destroy, or update a virtual tree |
Roact.createRef / Roact.Ref | Obtain a direct reference to a rendered Instance |
Roact.forwardRef | Create a component that forwards a ref to a child Instance |
Roact.createBinding / joinBindings | Reactive values for zero-overhead property updates |
Roact.createContext | Share data through the component tree without prop-drilling |
Roact.Portal | Render children into a different part of the Instance tree |
Roact.oneChild | Utility to safely unwrap a single child from a children table |
Roact.None | Sentinel value to explicitly remove a property from an Instance |
Roact.Event / Change / Children | Prop markers for events, property-change handlers, and children |
How Roact differs from direct Instance manipulation
Direct manipulation works fine for simple, static UI, but it scales poorly. When state changes you must remember which Instances to update and in what order. Roact eliminates this bookkeeping: re-render your component with new state and the reconciler figures out the minimum set of changes needed. Lifecycle hooks let you run setup and teardown logic at precisely the right moment, and context lets you share data across deep trees without threading props through every intermediate layer.Roact’s API is intentionally very close to React’s. If you already know React, most concepts transfer directly. The main differences are Roblox-specific: class names like
"TextLabel" instead of HTML tags, UDim2 and Color3 values instead of CSS strings, and Roact.Event/Roact.Change instead of onClick-style props.