Skip to content

Cratis Components: React UI for Arc commands and queries

Last released · v4.40.0

Cratis Components is a React UI library for building forms, command dialogs, and list screens with Cratis Arc. It connects those screens to Arc’s generated proxies: TypeScript classes that run your backend commands and queries from the browser. You can also display already-loaded rows or edit local React state. Components is part of Cratis Platform; Cratis Chronicle is not required.

Cratis Components

React components wired to your proxies

Compose a screen around generated commands and queries instead of repeating the execution, validation, and query-result UI wiring. Keep control of the layout and appearance through Cratis-owned React APIs, documented parts, and design tokens.

For an add or edit flow, give CommandDialog a generated command and the fields the user needs to fill in. It binds those fields, uses command validation to control confirmation, and tracks execution, so you do not maintain a second set of execution-state flags.

For a list, give a query-backed table the generated query and describe its columns. The table uses Arc’s hooks for results and paging. Observable queries deliver later results as the data changes; DataTableCore accepts already-loaded rows when your application owns the updates.

Keep your application’s appearance by mapping design tokens onto --cratis-* variables and styling documented data-cratis-part elements, or start with the optional baseline theme. React Aria supplies selected interaction primitives internally; it is not the public styling API.

Read why Components for the trade-offs. You still own query scope, selected identifiers, backend failure handling, and application-level accessibility checks. Command success does not guarantee that a separate read model, the data a query reads, is already current.

For your first working component, install and open an add-author dialog. That guide starts from a running Arc backend and generated proxies, and links to the backend setup if you need it. Then build the library screen around an author table and the selected author’s books. Installing the UI package alone does not create the backend or proxies. Chronicle is optional behind Arc.

Already have rows in memory or local input to edit? Choose the matching component before adding a command or query. Those components can use application-owned state without running an Arc request, although Arc’s npm packages remain required peers.

Components 4 runs on React 19 with @cratis/arc and @cratis/arc.react >=20.3.1 <23; this checkout pins its Arc development dependencies to 22.156.2. After npm install @cratis/components@^4, put the stylesheets in your CSS entry file:

src/index.css
@import '@cratis/components/tokens';
@import '@cratis/components/styles';
@import '@cratis/components/theme'; /* optional baseline */

Then import that file once and mount Components’ provider inside Arc’s. This is a setup excerpt; YourApp stands for your application’s root component:

Excerpt: application entry
import 'reflect-metadata';
import './index.css';
import { Arc } from '@cratis/arc.react';
import { CratisComponentsProvider } from '@cratis/components';
export const App = () => (
<Arc>
<CratisComponentsProvider value={{ locale: 'en-US' }} toaster>
<YourApp />
</CratisComponentsProvider>
</Arc>
);

<Arc> supplies the runtime used by generated commands and queries; CratisComponentsProvider supplies UI configuration, not a backend connection. Importing styles from CSS also avoids TypeScript 6’s TS2882 for the package’s untyped stylesheet subpaths. Getting started includes the peer installation, CSS module typing, and first command dialog. The package root is setup-only: import the provider and configuration helpers there, then import every component from its explicit subpath, such as @cratis/components/CommandDialog or @cratis/components/DataTables. The built-in renderer is zero-configuration. Optional renderer packages are selected explicitly; the application retains their provider, peer, server-side rendering (SSR), styling, and license responsibilities. Read Renderer adapters and coexistence for the exact nine-slot boundary, direct vendor coexistence, custom composition, unsupported claims, and licensing policy.

Use CommandDialog and CommandForm fields to collect input, query wrappers to display results, or StepperCommandDialog to gather a command’s values across named stages. The list screen recipe combines rows, dialogs, toolbar actions, and selection details.

Choose command input for typed fields, forms, and dialogs; data display for tables and list pages; application surfaces for dialogs, notifications, and page chrome; or structured editors for JSON content and schemas. The component decision guide also covers navigation, canvas, pivot, and time-oriented views.

Components consumes generated command/query contracts and React contexts from Arc. Applications may use Arc without Components, and Arc does not require event sourcing. Applications that use Chronicle can render its projected read models through these surfaces.

Optional renderer packages have their own provider, dependency, styling, server-rendering, and license requirements. Check the renderer’s setup before adding it.

For package metadata, use Components on npm. For implementation and contribution paths, use the Components source. The Arc documentation covers the generated application contracts; Chronicle documentation covers event-sourced storage and projected read models.