UI architecture
Understand how components, parts, blocks, templates and libraries relate.
Objects and relationships
| Object | Relationship | Example |
|---|---|---|
| Primitive | Supplies focused behavior or structure used by components | Base UI selection behavior, SharedBackground |
| Component | Provides a reusable public API. Can use primitives and other components | Select, ToolApproval, Chat |
| Part | Belongs to a component's public API and composition | Select.Trigger, Select.Popup |
| Block | Assembles components with task-specific content, state and actions | Source enrichment with selection, progress, cancellation and retry |
| Template | Assembles components and blocks with application structure and setup | An application starter with routes and connected workflows |
A component can compose another component. A primitive can also expose a public component API. SharedBackground, for example, provides focused structure and is available as a Ghost component.
A block supplies a concrete workflow that an adopter can change. A template supplies the surrounding application structure and setup. Both can contain React components in their implementation.
One job, one owner
Search the existing component and library before adding a public name. Extend the owner when the new need shares its behavior. Compose owners when the task combines several jobs. Keep local helpers private until another caller needs their contract.
For example, ToolApproval composes Card, Button and Dropdown menu. It provides an approval API with request identity, decision states and callbacks. Chat provides a reusable frame and input policy. Both remain components as their compositions grow. See Tool, Chat and the save-action example.
Patterns, examples and conditions
| Term | Meaning | Example |
|---|---|---|
| Pattern | A reusable solution to a user problem. Components, blocks and templates can implement it | Ask for approval before an action runs |
| Example | A demonstration of a component, pattern, block or template | ToolApproval placed beside a composer |
| Variant | A named supported choice on an API axis | Select.Trigger with the ghost variant |
| Configuration | A combination of supported options and parts | Grouped options in a compact Select |
| State | A condition during use | Pending, invalid, disabled or expired |
A pattern can have several implementations. Approval can appear in a message, a composer or a dialog. Each example should teach a useful decision. Keep one source for each example and link to it from related guides and catalogs.
A Model Selector API could compose Select or Combobox and retain its own reusable contract. A generation block could use that selector, accept a prompt, submit a job and show recovery. A template could connect that block to a canvas, assets and history. Choose the object by the contract an adopter receives.
Domain libraries
A library groups related components, utilities and contracts for a domain. It can include adapters and related blocks. For example, the AI library groups Chat, ToolApproval, message contracts and runtime adapters. Theme tokens supply shared visual values to the components and compositions.
Libraries covers scheduling, emoji/icons, tables, charts, forms and AI interfaces. Each library guide explains installation, data, state and integration, then links to its component APIs. Check the guide for the available package and registry entries.
API structure
Use native semantics and familiar prop names. Keep independent choices independent, use finite values for exclusive choices and expose useful parts for custom composition. A convenience wrapper should use the same parts. Keep application data, transport, persistence and side effects explicit and caller-owned.
For AI views, keep SDK-free contracts separate from optional adapters. React UI remains React even when the data contracts work with multiple runtimes. See the Component design skill for the full API and code structure guide.