Skip to content
AI-Ready Docs
/llms.txt/llms-mcp.txt

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 ​

OperationComponentsResult
Closed planar profileRectangle, Circle, Polygon, Loop, ProfileProfile input for Extrude or Revolve
Solid extrusionExtrudeExisting native extrusion of one profile
Solid revolutionRevolveExisting sketch-axis revolution of one closed profile
Solid unionUnionJoin at least two realized solids
Ordered subtractionDifference, Target, ToolsSubtract tools from one target
Rigid placementTranslate, RotateExisting Model body-transform nodes
ReuseDefinitions, typed object refsShare a declared profile or solid within one Part
Model lifecyclePart, ModelHostCommit declarations and coordinate an injected engine
DisplayExistingViewerHostSend 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 ​

tsx
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 pointRuntime exports
@barocss/cad-reactPart, Rectangle, Circle, Polygon, Loop, LineSegment, ArcSegment, Profile, Outer, Voids, Extrude, Revolve, Union, Difference, Target, Tools, Definitions, Translate, Rotate, CompositionCompiler, IrError
@barocss/cad-react/engineModelHost
@barocss/cad-react/viewerExistingViewerHost

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).