<board />
The <board />
element is a root element that contains all the chips and traces
to create a PCB.
You can think of a <board />
like a <body />
element in HTML. Everything
goes in a board!
export default () => (
<board width="10mm" height="10mm">
<resistor resistance="1k" footprint="0402" name="R1" />
</board>
)
Board Properties
Customizing the Size of the Board
Generally you'll use the width
and height
properties to define the size of
the board.
Rounding Board Corners with borderRadius
To soften sharp corners on a rectangular board, set the optional borderRadius
prop. You can pass the radius as either a number—interpreted in millimeters—or
as a string like "2mm"
. The radius is applied uniformly to all four corners.
export default () => (
<board width="20mm" height="15mm" borderRadius="3mm">
<chip name="U1" footprint="qfn32" pcbX={0} pcbY={0} />
<resistor name="R1" resistance="1k" footprint="0402" pcbX={5} pcbY={3} />
<resistor name="R2" resistance="10k" footprint="0402" pcbX={-5} pcbY={-3} />
</board>
)
Configuring the Layer Stack with layers
You can set the layers
prop to add additional inner layers to your circuit
board. If you specify layers={4}
, the "inner1"
and "inner2"
layers are
added automatically and available for routing, while omitting the prop keeps the
default two-layer stackup.
The following example enables a four-layer board and shows traces connecting components across that stackup:
export default () => (
<board
width="32mm"
height="20mm"
layers={4}
>
<chip name="U1" footprint="soic8" pcbX={-6} pcbY={0} />
<chip name="U2" footprint="soic8" pcbX={6} pcbY={0} rotation={180} />
<trace from=".U1 > .pin1" to=".U2 > .pin5" />
<trace from=".U1 > .pin2" to=".U2 > .pin6" />
<trace from=".U1 > .pin3" to=".U2 > .pin7" />
<trace from=".U1 > .pin4" to=".U2 > .pin8" />
</board>
)
Setting the autorouter
Boards or subcircuits can specify what autorouter should be used to route any traces within them.
Usually you'll want to use an autorouter preset:
autorouter="auto"
- Uses the platform configuration. For tscircuit.com this defaults tosequential-trace
.autorouter="sequential-trace"
- Iterate over each trace and use tscircuit's fast built-in autorouter. This method is fast and deterministic but often fails with over 50 traces.autorouter="auto-local"
- Use the platform configuration, but only route locally (do not make API calls)autorouter="auto-cloud"
- Use the platform configuration for
For complex boards with over 50 traces, you should use autorouter="auto-cloud"
to take advantage of tscircuit's cloud autorouters, which internally use the popular
freerouting library.
You can also specify a custom autorouter object to use your own autorouter.
export default () => (
<board
width="20mm"
height="20mm"
autorouter={{
serverUrl: "https://registry-api.tscircuit.com",
serverMode: "job",
inputFormat: "simplified",
}}
>
<chip name="U1" footprint="soic8" pcbX={5} pcbY={0} />
<resistor
name="R1"
pcbX={-5}
pcbY={0}
resistance={100}
footprint="0402"
/>
<trace from=".U1 > .pin1" to=".R1 > .pin1" />
</board>
)
Learn more about the Autorouting API here
Custom Board Outlines
You can specify a custom outline for your board by passing an outline
prop.
The PCB you get will have this outline cut out, this is great when you want a
board that's not a rectangle!
export default () => (
<board
outline={[
{ x: -22.5, y: 24.5 },
{ x: 22.5, y: 24.5 },
{ x: 22.5, y: 16.5 },
{ x: 20.5, y: 16.5 },
{ x: 20.5, y: 12.5 },
{ x: 22.5, y: 12.5 },
{ x: 22.5, y: 2.5 },
{ x: 18, y: -1.5 },
{ x: 18, y: -18 },
{ x: -18, y: -18 },
{ x: -18, y: -1.5 },
{ x: -22.5, y: 2.5 },
{ x: -22.5, y: 12.5 },
{ x: -20.5, y: 12.5 },
{ x: -20.5, y: 16.5 },
{ x: -22.5, y: 16.5 },
{ x: -22.5, y: 24.5 },
]}
// These are currently required due to this issue:
// https://github.com/tscircuit/core/issues/564
width="50mm"
height="50mm"
/>
)
Offseting the board origin
width
and height
set the board's bounding box (and thus the pcbX
/pcbY
coordinate system) even when you're using a custom outline. Add
outlineOffsetX
and outlineOffsetY
—measured in millimeters, whether passed as
numbers or strings like "5mm"
—to slide that outline relative to the bounding
box so (0, 0)
lands where you expect. Positive offsets push the outline toward
increasing pcbX
/pcbY
coordinates.
In this example the outline is shifted half the board's width and height so the origin stays at the lower-left corner while the shape itself is centered:
export default () => (
<board
width="40mm"
height="30mm"
outlineOffsetX="20mm"
outlineOffsetY="15mm"
>
<chip name="U1" footprint="qfn32" pcbX={5} pcbY={5} />
<resistor name="R1" footprint="0402" resistance="1k" pcbX={10} pcbY={12} />
</board>
)
Board Anchor Properties
You can control the board's position and alignment using anchor properties:
boardAnchorPosition
: Moves the board's anchor point to the specified coordinatesboardAnchorAlignment
: Sets which part of the board the anchor point refers to
export default () => (
<board
width="10mm"
height="10mm"
boardAnchorPosition={{x:0, y:0}}
boardAnchorAlignment="bottom_left"
>
<resistor resistance="1k" footprint="0402" name="R1" pcbX={2} pcbY={2} />
<fabricationnotetext text="(5,5)" anchorAlignment="bottom_left" fontSize="0.5mm" pcbX={5} pcbY={5} />
<fabricationnotetext text="(10,10)" anchorAlignment="bottom_left" fontSize="0.5mm" pcbX={10} pcbY={10} />
<fabricationnotetext text="(0,0)" anchorAlignment="bottom_left" fontSize="0.5mm" pcbX={0} pcbY={0} />
</board>
)
Try Different Alignments
// This moves the board's center to position (1,2)
<board
boardAnchorPosition={{x:1, y:2}}
boardAnchorAlignment="center" // Try changing this to other values
width="10mm"
height="10mm"
>
<resistor resistance="1k" footprint="0402" name="R1" />
</board>
How Anchoring Works
- The
boardAnchorAlignment
determines which point on the board is considered the anchor point - The
boardAnchorPosition
moves that anchor point to the specified (x,y) coordinates
Example Alignments:
"center"
- Board is centered on the anchor point"top_left"
- Top-left corner is at the anchor point"top_right"
- Top-right corner is at the anchor point"bottom_left"
- Bottom-left corner is at the anchor point"bottom_right"
- Bottom-right corner is at the anchor point"center_left"
- Middle of the left edge is at the anchor point"center_right"
- Middle of the right edge is at the anchor point"top_center"
- Top center point is at the anchor point"bottom_center"
- Bottom center point is at the anchor point
Flexible PCBs
Interested in flexible PCBs? Upvote this issue on Github!