Skip to content

Cratis Components UI foundation and public contracts

Cratis Components gives React applications UI contracts for command forms, query-backed tables, and other interactive views. Use it when you want those screens to share typed props and styling hooks while Arc handles command and query execution. Components owns the public markup, types, and behavior; it does not provide a framework-neutral UI layer or require Chronicle.

That ownership lets you style documented parts instead of depending on an internal library’s markup. It also sets an adoption boundary: Components uses React and browser DOM semantics, and an optional renderer adapter changes selected controls rather than replacing an entire screen.

Components 3 used PrimeReact, PrimeIcons, and PrimeUI theme packages as its foundation. Components 4 removes Prime dependencies and peers from @cratis/components, including Prime imports and type references in emitted JavaScript and declarations.

If you are migrating, target Components-owned props, typed parts, data-cratis-part attributes, and table contracts rather than the former Prime renderer contracts. Styling uses --cratis-* tokens instead of a third-party theme preset. Direct Prime usage in your application remains your responsibility; see the Prime dependency boundary. React Aria still supplies selected interactions internally, but is not a public styling or prop contract; Why React Aria explains that choice.

graph TD
    App[Consumer application] --> Components[@cratis/components]
    Components --> Contracts[Cratis-owned APIs, parts, tokens, and state attributes]
    Components --> Aria[React Aria interaction behavior]
    Components --> Native[Semantic native HTML]
    Components --> Arc[@cratis/arc.react bindings]

Consumers import @cratis/components/*. React Aria does not appear in public prop types, declarations, or styling contracts. Arc command, query, and dialog bindings remain owned by @cratis/arc.react; Components builds visual behavior around them.

The public contract deliberately uses React refs, native HTML attributes and element types, DOM events, and native form behavior where each component exposes them. “Renderer-independent” means you target Components’ contract rather than an internal vendor’s types or styling hooks. It does not mean the components can render in another frontend framework.

Arc owns command and query execution and its generated client contracts. Components adds visual interaction around those contracts. Chronicle can supply the backend’s event history and projected read models, but Components has no direct Chronicle dependency. An Arc backend using current-state storage can serve the same kind of UI; persistence is a backend choice, not a renderer choice.

The accepted DOM-coupled public contract records that boundary. The accepted component classification records which public exports are visual primitives, interaction primitives, high-order composites, or interop-only components.

To integrate an existing design system, use the documented styling surfaces:

  • Semantic color, surface, border, radius, and focus variables under --cratis-*.
  • Typed pt keys for foundation components that support per-instance part attributes.
  • Stable data-cratis-part values and component-specific state attributes documented in Stable component parts.
  • className and style on public roots where applicable.
  • Standard HTML attributes, native element refs, DOM events, and native form semantics where a component exposes them.
  • Baseline light/dark/forced-colors values in the optional theme.

Spacing, typography, motion, elevation, and product-specific dimensions remain product design-system concerns unless a component documents a dedicated token or prop. A product can map its own token families to the Cratis semantic values and style stable parts without targeting React Aria DOM.

Import surface: setup-only root, explicit subpaths

Section titled “Import surface: setup-only root, explicit subpaths”

Import application-wide setup from the package root and components from explicit subpaths. These imports illustrate the boundary; they are not a complete application setup:

// Setup surface — root
import { CratisComponentsProvider } from '@cratis/components';
// Components — explicit subpaths
import { CommandDialog } from '@cratis/components/CommandDialog';
import { DataTableForQuery, Column } from '@cratis/components/DataTables';
import { Canvas, CanvasItem } from '@cratis/components/Canvas';

The root exports CratisComponentsProvider, useCratisComponentsConfig, cratisDefaults, mergeCratisComponentsConfig, useCratisIcon, and configuration, message, icon, and dialog integration types. Component families in every capability profile are reached through their own subpaths, not the root.

Components 4 removes the Components 3 component-family namespaces from the root. Imports such as import { Canvas } from '@cratis/components' no longer resolve; use @cratis/components/Canvas instead. Migrate from Components 3 to 4 carries the current namespace-to-subpath mapping, codemod command, and stop conditions. The CommandStepper mapping is intentionally special: the historical namespace represented the full CommandDialog module, so it migrates to @cratis/components/CommandDialog; the narrower @cratis/components/CommandStepper subpath exports only the standalone component.

The profiles below help you choose which subpaths to use. They group components by purpose and dependency needs, not by separate packages or release versions:

  • Foundation covers forms, dialogs, tables, and notifications: Common, CommandDialog, CommandStepper, CommandForm, CommandForm/fields, DataPage, DataTables, Dialogs, Display, Dropdown, Filter, Notifications, and types.
  • Advanced React covers more specialized screens: Chat, ObjectContentEditor, ObjectNavigationalBar, SchemaEditor, TimeMachine, and Toolbar. These use React and DOM rendering without Pixi.
  • Spatial covers Canvas and PivotViewer, which require the optional pixi.js peer; see Optional Pixi, clean no-Pixi core.

All three profiles and the setup-only root share one package version. The package also exports controls such as ConfigurationEditor, IconPicker, and MarkdownEditor; the profiles are an adoption guide, not an exhaustive export list. Check the package manifest and the component’s own documentation for its exact requirements.

Surface Use it for Data boundary Pixi required?
Setup root Locale, messages, icons, and provider configuration No Arc or Pixi import in the root’s runtime or declaration graph No
Foundation Forms, dialogs, and query-backed tables Arc executes commands and queries; Components owns visual interaction state No
Advanced React Conversations, editors, navigation, and tool palettes Mostly host-supplied props; Chat also offers Arc query and messaging bindings No
Spatial Pan/zoom views and card collections The host supplies items; Components owns viewport and visualization state Yes, one shared compatible pixi.js resolution

Components does not persist application data. Local-data components can render values you supply without using an Arc query, but that does not remove the package’s declared peer requirements. React 19, ReactDOM 19, Arc, Fundamentals, and reflect-metadata are declared peers; Pixi and tsyringe are optional peers. The setup-only root has no Arc import edge even though the package declares Arc peers.

Server rendering also differs from browser interaction. Importing a surface without Pixi is a dependency guarantee, not proof that every interaction works on the server. Portals, focus handling, canvas rendering, and workers need their documented browser setup. Use the Canvas and PivotViewer references for their rendering and worker boundaries. For existing tables, Update tables explains the move to loaded-page controls.

Only the Spatial profile touches Pixi. Canvas and PivotViewer are the only subpaths that import pixi.js; every Foundation and Advanced React subpath — including Toolbar, which looks canvas-adjacent by name — is plain React and DOM, with no Pixi reference anywhere in its module graph.

pixi.js is declared as an optional peer (peerDependenciesMeta: { "pixi.js": { "optional": true } }), not a Components dependency:

Terminal window
npm install pixi.js@^8.20.0

Install it in the application only when using Canvas or PivotViewer. Keep one compatible Pixi resolution shared by the application and Components. Duplicate installations can give PIXI.Container and pointer-event types incompatible identities, even when their versions satisfy the same peer range.

Canvas exposes real Pixi objects through CanvasContext, renderItem, and pointer callbacks so you can build content against that shared instance. PivotViewer uses Pixi internally without exposing those types. See Strict public-type validation for the version boundary that affects strict TypeScript consumers.

Canvas can combine DOM content positioned through CanvasItem with a Pixi items/renderItem layer. You can use only the DOM layer, or mix both; importing the Canvas subpath still requires the Pixi peer. Canvas: DOM and Pixi layers explains when to choose each layer. Foundation and Advanced React imports do not require Pixi.

Component JavaScript does not import CSS. Choose either the aggregate @cratis/components/styles or the shared @cratis/components/styles/base with the per-area sheets your application needs, such as @cratis/components/Dialogs/styles and @cratis/components/PivotViewer/styles.

The aggregate is the simpler setup: it includes styling across all three profiles, including components you do not render. That costs CSS transfer and parsing, but does not import Pixi or component JavaScript. Per-area sheets let a smaller application avoid unrelated styles. Follow Per-area stylesheets for the required base and component imports.

Both paths derive from Source/styles.css. Per-area output follows the component’s module graph, so a sheet includes styles for the areas its implementation uses, not only its own folder. Keeping CSS outside the JavaScript graph also lets Node import component modules without trying to load .css files. The package checks stylesheet coverage and emitted exports, and the archive verifier enforces raw-size, gzip-size, and declaration-block budgets.

Separate stylesheets do not mean separate packages or release versions. The next section explains that distinction.

@cratis/components ships the three capability profiles together. Subpath imports isolate JavaScript dependencies, and per-area styles let you select CSS, but installing the package still gives you its full distribution. Choosing only Foundation does not create a smaller npm package or a separate upgrade schedule.

A package split would address a different need: a smaller installed distribution, independent release versions, or a separately supported non-visual contract. The current package does not offer those boundaries. In particular, table state remains part of React composition, not a separately exported framework-neutral engine.

Use the built-in renderer by mounting CratisComponentsProvider without a library prop. If your application already uses another control library, an adapter can change the presentation of nine primitives through the stable-presentation/v1 profile: button, icon button, text input, text area, checkbox, radio, switch, progress, and surface.

An adapter does not replace CommandForm, CommandDialog, DataTables, Canvas, or other Components compositions. It also does not replace Arc’s provider or execution state. The public renderer contract lives at @cratis/components/renderer; importing it or the setup root does not load the full built-in manifest. That manifest is an explicit import from @cratis/components/renderer/builtin.

Keep vendor providers, themes, credentials, and caches in application setup. CratisRendererSetup carries only adapter-declared boolean setup assertions, not those resources. CratisOverlayEnvironment lets the host resolve a portal container; it does not merge vendor overlay or z-index systems. When both systems open overlays, the application must coordinate their containers, layers, and focus behavior.

Renderer adapters and coexistence explains adapter selection and vendor setup. Broader renderer APIs retain their unstable_ names and are outside the nine-slot compatibility contract.

React Aria Components supplies selected focus, keyboard, screen-reader, overlay, collection, and date interactions without supplying Components’ visual design.

Components still owns labels, error association, visual focus, contrast, hit targets, responsive composition, and behavior specs. React Aria is not treated as proof that a composed component is automatically accessible.

Components 4 supplies its own toast queue, dispatch, timer, frame, and accessible region rather than exposing React Aria’s Toast API.

A query-backed table combines two responsibilities. Arc retrieves and pages query results; Components renders semantic HTML and manages the table’s visual interaction state. DataTableCore is a rendered React component, not a headless or framework-neutral table engine.

By default, client filtering and sorting affect only the loaded page. To search or sort the complete result, opt into serverQuery and implement the corresponding backend query logic before paging. Components maps sort state to Arc sorting and maps filters and search text to the query arguments you define. It does not infer those arguments or apply server filtering for you. Server mode shows the handoff.

The Components 4 package manifest does not declare PrimeReact, PrimeIcons, PrimeUI, or PrimeUI theme packages as dependencies or peers. Applications that still import those packages directly retain their own package, provider, styling, version, and license boundaries. Review the exact third-party package terms for the version an application keeps; this page makes no licensing conclusion for that application.

Why Components does not implement every interaction itself

Section titled “Why Components does not implement every interaction itself”

Dialog focus traps, composite keyboard navigation, calendars, and collection selection have interaction rules beyond their visual appearance. Components delegates selected behavior to React Aria and uses semantic native HTML for simple controls. This keeps the public contract under Components’ control without making every interaction a separate implementation.

Application composition still matters. Verify keyboard order, focus restoration, and screen-reader output in the shell where the components will run; the choice of interaction library does not certify the finished application.

Moving from Components 3 to 4 changes the foundation, import paths, provider setup, and styling contracts. Follow Migrate from Components 3 to 4 for the breaking changes and mechanical import mapping. The guide does not establish a maintenance window for either major.

Adapter authors can use the separate @cratis/components.conformance package to check a renderer manifest. Conformance results cover the exercised contract and environment, not universal behavior parity or accessibility. Browser and axe checks remain separate release requirements.

Check your application’s declarations with its TypeScript compiler and module-resolution mode. With skipLibCheck: false, earlier releases of the @cratis/arc.react peer can report TS2503 for unresolved JSX identifiers in command/dialog subpaths. Resolve Arc 22.156.2 or later, which excludes its test-only global JSX declarations. The Components peer range still admits earlier Arc releases.

Why the Canvas Pixi surface remains public

Section titled “Why the Canvas Pixi surface remains public”

CanvasContext, renderItem, and pointer callbacks expose real Pixi objects so you can build content without converting to a reduced Components facade. That makes the installed Pixi version part of Canvas’s type-checking boundary.

The repository pins pixi.js@8.22.0 for development and verification, while the ^8.20.0 peer range also admits 8.20.x and 8.21.x. Strict consumers (skipLibCheck: false) on those earlier releases can encounter a WebGPU declaration conflict; use 8.22.0 or later. Keep one shared compatible resolution, as described under Optional Pixi, clean no-Pixi core. PivotViewer does not expose Pixi types publicly.

Values the Designsystemet bridge does not reach

Section titled “Values the Designsystemet bridge does not reach”

The Designsystemet bridge maps the colour, radius, size, focus, shadow, and disabled tokens. Components draw focus with --cratis-focus-ring plus an optional outline from --cratis-focus-outline and --cratis-focus-outline-offset, which default to none and 0 so the default look does not change. The control heights follow Designsystemet’s data-size (sm, md, lg). The Cratis data-size values on Button, Avatar, and Badge are a separate vocabulary.

The type and radius scales are tokens (--cratis-font-size-xs, -sm, -md, --cratis-type-weight-medium, -semibold, -bold, --cratis-corner-sm, -lg, -xl, -full) whose defaults equal the values they replaced. Only stylesheets for the common controls, the dropdown, filters, the toolbar, notifications, the data table core, the command form fields, the dialog, the table paginator, and the object navigational bar read them. These stay as fixed values and follow the product, not the bridge:

  • Paddings, gaps, and line heights.
  • The number input step buttons and the icon picker tiles, which draw a primary-colour outline of their own instead of the shared focus ring.
  • Canvas and Chat, which do not read the new tokens or the focus outline hook.
  • Font sizes with no token, such as 0.8125rem, 0.85rem, 13px, 12px, and 11px.
  • Radii other than 4px, 8px, 12px, and 999px, and 50% circles.
  • Literal shadows in menus and popovers.
  • The forced-colors Highlight outlines.
  • TimeMachine, SchemaEditor, MarkdownEditor, IconPicker, ConfigurationEditor, PivotViewer, and Display take the focus outline hook only where they draw a keyboard focus ring. Their literal sizes and radii are not tokenised.
  • The backdrop (--cratis-maskbg) and the --cratis-z-index-* tokens, which Designsystemet has no equivalent for.
  • The status colours: the bridge uses Designsystemet’s tinted surface pairs where the Cratis default uses solid pairs.

  • Complete-result filtering and sorting must happen in the server query before paging; loaded-page controls operate only on the loaded page.
  • Some generated labels and plural/relative text cannot be replaced through the provider’s message options.
  • Renderer adapters replace only the nine slots in stable-presentation/v1, not the full component catalog.

For renderer setup, use Renderer adapters and coexistence. When upgrading an existing application, follow Migrate from Components 3 to 4.