CAD React
@barocss/cad-react is a private workspace package. It describes CAD geometry with ordinary React components, lowers the committed geometry to the existing CAD Model document, and can connect an injected engine to the existing Viewer.
The current package is TypeScript source in this repository. It is not a published npm package, a portable engine client, a distribution build or a standalone Worker. The host application supplies the engine, Worker setup and mass integration. Add it to a workspace consumer with workspace:*.
What you can compose
| Operation | Components | Result |
|---|---|---|
| Closed planar profile | Rectangle, Circle, Polygon, Loop, Profile | Profile input for Extrude or Revolve |
| Solid extrusion | Extrude | Existing native extrusion of one profile |
| Solid revolution | Revolve | Existing sketch-axis revolution of one closed profile |
| Solid union | Union | Join at least two realized solids |
| Ordered subtraction | Difference, Target, Tools | Subtract tools from one target |
| Rigid placement | Translate, Rotate | Existing Model body-transform nodes |
| Reuse | Definitions, typed object refs | Share a declared profile or solid within one Part |
| Model lifecycle | Part, ModelHost | Commit declarations and coordinate an injected engine |
| Display | ExistingViewerHost | Send engine display meshes to the existing Viewer |
Read the component catalog, references and compiler, engine and Viewer integration, examples and support boundaries.
A Part is a model root
import {
Part, Extrude, Rectangle, type ModelLifecycle,
} from '@barocss/cad-react';
export function Plate({ lifecycle }: { lifecycle: ModelLifecycle }) {
return <Part admission="synchronous" lifecycle={lifecycle} units="mm">
<Extrude distance={6}>
<Rectangle min={[0,0]} max={[80,60]} />
</Extrude>
</Part>;
}This declaration produces a model. It does not create an engine or a visible canvas by itself. Pass an appropriate lifecycle, such as a connected ModelHost, and provide the display integration.
React runs normal function components and hooks. Committed hidden DOM markers record membership and sibling order. The compiler does not call your component functions manually and does not infer their output from React.Children alone. Native feature IDs are automatic; no manual Sketch IDs or native body references are required.
For the complete existing ModelNode inventory and the missing adapter backlog, read the CAD Model support map. Existing backend operations are broader than this first React subset; this page does not claim full CAD React coverage.
Public entry points
| Entry point | Runtime exports |
|---|---|
@barocss/cad-react | Part, Rectangle, Circle, Polygon, Loop, LineSegment, ArcSegment, Profile, Outer, Voids, Extrude, Revolve, Union, Difference, Target, Tools, Definitions, Translate, Rotate, CompositionCompiler, IrError |
@barocss/cad-react/engine | ModelHost |
@barocss/cad-react/viewer | ExistingViewerHost |
All public type exports are listed with their contracts on the component, references and engine pages. The package also exposes @barocss/cad-react/sdk (<CadViewport />, <CadDrawing />) used by BaroCSS Review and embedded CAD experiences. Examples use standard React hooks (useRef, useState, useEffect).