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

Components and props ​

Import these components from @barocss/cad-react. Coordinates and lengths are in millimetres. Profiles are local XY geometry; extrusion and transforms lower to the existing Model operations. A React wrapper may return a compatible realized output: validation concerns the committed geometry, not the raw JSX child count.

Detailed component pages ​

Each supported React element has its own props, complete example, logical/native role, validation and measured-scope page.

Root and profilesSolid operationsOperand slots and reusePlacement
PartExtrudeTargetTranslate
RectangleUnionToolsRotate
CircleDifferenceDefinitions
PolygonRevolve

Part ​

PropContract
lifecycleRequired ModelLifecycle object
admissionRequired literal "synchronous"; caller promises the supported synchronous composition boundary
unitsOptional "mm", default "mm"
childrenRequired React children producing exactly one solid output outside Definitions

ModelLifecycle has dirty():void, invalid(error:unknown):void, complete(model:Compiled):void and detached():void. A connected ModelHost implements this interface. Each Part is a separate model root; nested Parts are not geometry operands. Part is not a canvas and does not create a Worker.

Profiles ​

ComponentPropsOutput
Rectanglemin:[x,y], max:[x,y], optional ref:ProfileRefClosed profile with strictly positive X/Y extents
Circlecenter:[x,y], positive finite radius, optional ref:ProfileRefClosed circular profile
Polygonpoints:readonly [x,y][] with 3..1024 dense finite pairs, optional ref:ProfileRefClosed ordered profile

Supply dense finite coordinate tuples. These components are profile producers, not standalone solid bodies. They do not expose a native face, a selected region, an arbitrary wire or a sketch-constraint editor.

Polygon ​

Polygon accepts a readonly array of 3..1024 ordered dense finite coordinate pairs and optional ProfileRef. It produces one closed profile through existing polygon sketch storage. PolygonProps is exported. Native validity and refusal remain authoritative; no points are repaired, removed or resampled.

Extrude ​

PropContract
distanceRequired finite nonzero length; positive and negative values lower to the existing native height
fromOptional finite start coordinate along the local extrusion direction; omitted by default
childrenExactly one realized profile, exclusive with profile
profileProfileRef, exclusive with children
refOptional SolidRef for the resulting solid

ExtrudeProps is the public prop type. The input is profile geometry. An internal Sketch node is a document-storage detail, not a public sketch={...} prop. Native face/region extrusion available elsewhere in Studio is not automatically a source capability here.

Revolve ​

Revolve accepts one closed profile child or typed profile reference, required sketch axis="x"|"y", required finite angle in (0,360] degrees and optional finite two-coordinate origin. It returns a solid reference. The adapter lowers the existing Model node; it adds no native math. Declaration/types/lint checks and the selected rectangle90/180/360/Reset 90 actual flow pass; broader profile/axis/origin combinations remain unqualified. Read the Revolve contract.

Union and Difference ​

ComponentPropsContract
Unionchildren, optional ref:SolidRefAt least two realized solid operands; combines them in declared order
Differencechildren, optional ref:SolidRefExactly one Target and one Tools group
TargetOne solid child or solid:SolidRefThe solid to cut; TargetProps is exported
ToolschildrenOne or more realized solid tools, subtracted in declared order
tsx
import { Difference, Target, Tools, Extrude, Rectangle, Circle } from '@barocss/cad-react';

export function HoledPlate() {
  return <Difference>
    <Target><Extrude distance={6}><Rectangle min={[0,0]} max={[80,60]} /></Extrude></Target>
    <Tools><Extrude from={-1} distance={8}><Circle center={[10,10]} radius={3} /></Extrude></Tools>
  </Difference>;
}

This is existing CAD Boolean evaluation, with the backend's native geometry/refusal limits. The JSX layer does not implement a new Boolean kernel or certify every operand arrangement.

Translate and Rotate ​

ComponentRequired propsOptional props
Translateoffset:[x,y,z], one solid inputref:SolidRef
Rotate`axis:"x""y"

A solid input is exactly one realized solid child or solid:SolidRef. SolidInput, TranslateProps and RotateProps are exported. Offset and explicit pivot require three finite coordinates, including all three indexed array elements. Sparse arrays refuse. Angle must be finite with absolute value at most 3600; zero is allowed. An omitted pivot remains omitted and uses the existing backend origin default.

tsx
import { Translate, Rotate, Extrude, Rectangle } from '@barocss/cad-react';

export function PositionedPlate() {
  return <Translate offset={[30,40,5]}>
    <Rotate axis="z" angle={90} pivot={[0,0,0]}>
      <Extrude distance={6}><Rectangle min={[0,0]} max={[80,60]} /></Extrude>
    </Rotate>
  </Translate>;
}

The inner Rotate lowers before the outer Translate. No matrix or trigonometry is computed by the React layer. Accepted axes/angles are API input rules; they do not expand the finite runtime evidence.

Definitions, refs and standard React behavior ​

Definitions takes children declaring profiles or solids for typed reuse. Its definitions do not add independent Part outputs. See references for ProfileHandle, SolidHandle, ProfileRef and SolidRef.

Normal function components, props, hooks, Fragments and keyed arrays can compose these components within synchronous admission. React keys and mounted identities preserve supported feature identity; remounting creates new identity. No component has a public native-ID prop. Internal Suspense/Offscreen/async behavior is outside admission, including when a wrapper hides it.

Profile composition ​

Loop, LineSegment, ArcSegment, Profile, Outer, and Voids compose multi-segment closed profiles with optional inner cutouts.

ComponentInput and role
LoopOrdered 1..1024 exact segment descriptors; optional profile ref
LineSegmentFinite start pair inside Loop; no native ID or ref
ArcSegmentFinite start/center and explicit ccw/cw direction inside Loop
ProfileExactly one Outer, optional one Voids; optional profile ref
OuterExactly one single-loop child or profile reference
Voids1..64 single-loop children or dense profile references

Profile and Loop produce typed profile data; Outer/Voids and LineSegment/ArcSegment are structural descriptors rather than independent native features. Composite Profile emits one consumed sketch cleanly, Circle converts via exact loops, and Extrude admits explicit voids within native bounds.

Hole ​

Hole cuts an existing solid with numeric center/radius and optional axis, side and flat-bottom depth. Supply one solid child or SolidRef. Omitted depth requests a through hole. Native geometry and refusal remain authoritative. This component does not expose face selection, pointed drilling, threads or patterns.

Declarative JSX DSL features (@barocss/cad-react/dsl) ​

In addition to the synchronous host components above, @barocss/cad-react/dsl exposes a pure-functional JSX modeling DSL compiled by compileCadElement / evaluateCadElement, including parametric param('name') references and six advanced solid modeling components:

ComponentPurposeKey Props
DraftTaper selected faces about a neutral planeangle, pull (CadDraftPull), neutral, selector (CadFaceSelector) or select callback
MirrorMirror a solid across a plane ('xy' | 'xz' | 'yz')plane (CadMirrorPlane), at, optional keep
SplitConserved planar split along an axis or oblique normalaxis or normal: [x, y, z], at
Loft & LoftSectionBlend two or more planar or framed profile sectionssmooth, child <LoftSection z={...}> or <LoftSection frame={...}>
SweepSweep a Circle or Profile along a stepped path or NURBS railpath (straight / bend segments) or curve (CadSweepCurvePath), mode
RibAdd a stiffening rib solid between bounding coordinates on a parent solidmin: [x, y, z], max: [x, y, z]
tsx
import {
  Part, Box, Draft, Mirror, Split, Loft, LoftSection, Sweep, Rib,
  Rectangle, Circle, param, evaluateCadElement,
} from '@barocss/cad-react/dsl';

const bracket = (
  <Part parameters={{ H: 20, N: 0, top: 18 }}>
    <Draft angle={5} pull="+z" neutral={param('N')} selector={{ facing: ['+x', '-x'], planar: true }}>
      <Mirror plane="yz" keep at={10}>
        <Rib min={[0, 5, 2]} max={[15, 8, param('top')]}>
          <Box width={20} depth={20} height={param('H')} />
        </Rib>
      </Mirror>
    </Draft>
  </Part>
);

const snapshot = evaluateCadElement(bracket);