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 profiles | Solid operations | Operand slots and reuse | Placement |
|---|---|---|---|
| Part | Extrude | Target | Translate |
| Rectangle | Union | Tools | Rotate |
| Circle | Difference | Definitions | |
| Polygon | Revolve |
Part
| Prop | Contract |
|---|---|
lifecycle | Required ModelLifecycle object |
admission | Required literal "synchronous"; caller promises the supported synchronous composition boundary |
units | Optional "mm", default "mm" |
children | Required 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
| Component | Props | Output |
|---|---|---|
Rectangle | min:[x,y], max:[x,y], optional ref:ProfileRef | Closed profile with strictly positive X/Y extents |
Circle | center:[x,y], positive finite radius, optional ref:ProfileRef | Closed circular profile |
Polygon | points:readonly [x,y][] with 3..1024 dense finite pairs, optional ref:ProfileRef | Closed 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
| Prop | Contract |
|---|---|
distance | Required finite nonzero length; positive and negative values lower to the existing native height |
from | Optional finite start coordinate along the local extrusion direction; omitted by default |
children | Exactly one realized profile, exclusive with profile |
profile | ProfileRef, exclusive with children |
ref | Optional 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
| Component | Props | Contract |
|---|---|---|
Union | children, optional ref:SolidRef | At least two realized solid operands; combines them in declared order |
Difference | children, optional ref:SolidRef | Exactly one Target and one Tools group |
Target | One solid child or solid:SolidRef | The solid to cut; TargetProps is exported |
Tools | children | One or more realized solid tools, subtracted in declared order |
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
| Component | Required props | Optional props |
|---|---|---|
Translate | offset:[x,y,z], one solid input | ref: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.
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.
| Component | Input and role |
|---|---|
| Loop | Ordered 1..1024 exact segment descriptors; optional profile ref |
| LineSegment | Finite start pair inside Loop; no native ID or ref |
| ArcSegment | Finite start/center and explicit ccw/cw direction inside Loop |
| Profile | Exactly one Outer, optional one Voids; optional profile ref |
| Outer | Exactly one single-loop child or profile reference |
| Voids | 1..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:
| Component | Purpose | Key Props |
|---|---|---|
Draft | Taper selected faces about a neutral plane | angle, pull (CadDraftPull), neutral, selector (CadFaceSelector) or select callback |
Mirror | Mirror a solid across a plane ('xy' | 'xz' | 'yz') | plane (CadMirrorPlane), at, optional keep |
Split | Conserved planar split along an axis or oblique normal | axis or normal: [x, y, z], at |
Loft & LoftSection | Blend two or more planar or framed profile sections | smooth, child <LoftSection z={...}> or <LoftSection frame={...}> |
Sweep | Sweep a Circle or Profile along a stepped path or NURBS rail | path (straight / bend segments) or curve (CadSweepCurvePath), mode |
Rib | Add a stiffening rib solid between bounding coordinates on a parent solid | min: [x, y, z], max: [x, y, z] |
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);