Skip to main content
Built-in Elements

<group />

A group is the basic container element that can contain other elements.

By default, a group doesn't have any effect on the circuit.

import { sel } from "tscircuit"

export default () => (
<board width="10mm" height="10mm">
<resistor name="R1" resistance="1k" schX={-2} />
<group schY={-3}>
<resistor name="R2" resistance="1k" schX={2} />
<trace from={sel.R1.pin2} to={sel.R2.pin1} />
</group>
</board>
)
Schematic Circuit Preview

Props

PropTypeDescription
namestringOptional identifier for the group element.
childrenanyElements that will be rendered inside the group.
schTitlestringTitle displayed above the group in the schematic view.
showAsSchematicBoxbooleanWhen true, renders the group as a single schematic box.
connectionsConnectionsMap of external pin names to internal connection targets.
schPinArrangementSchematicPinArrangementControls the ordering and sides of pins when shown as a schematic box.
schPinSpacingDistanceAdjusts the spacing between schematic pins in box mode.
schPinStyleSchematicPinStyleStyles applied to individual pins in schematic box mode.
pcbWidth / pcbHeightDistanceOverride the PCB footprint width or height for the group box.
schWidth / schHeightDistanceOverride the schematic box width or height.
pcbLayout / schLayoutLayoutConfigAdvanced layout configuration objects applied to PCB or schematic views.
cellBorder / borderBorder | nullCustom border styling for the group when rendered as a cell or schematic box.
schPadding*DistanceSets overall or per-side padding around schematic contents (schPadding, schPaddingLeft, etc.).
pcbPadding*DistanceSets overall or per-side padding around PCB contents (pcbPadding, pcbPaddingLeft, etc.).
pcbPositionAnchorAutocompleteString<typeof ninePointAnchor>Anchor used when interpreting pcbX/pcbY relative to pcbPosition.

Grid Layout Props

export default () => (
<board width="26mm" height="20mm">
<group pcbGrid pcbGridCols={2} pcbGridGap="1mm">
<resistor name="R1" resistance="1k" footprint="0402" />
<capacitor name="C1" capacitance="10uF" footprint="0402" />
<led name="LED1" color="red" footprint="0603" />
<chip name="U1" footprint="soic8" />
</group>
</board>
)
PCB Circuit Preview
PropTypeDescription
pcbGrid / schGridbooleanEnables CSS grid style layout in the PCB or schematic view.
pcbGridCols / schGridColsnumber | stringSets the number of columns in the grid.
pcbGridRows / schGridRowsnumber | stringSets the number of rows in the grid.
pcbGridTemplateRows / schGridTemplateRowsstringExplicit template row sizes for the grid.
pcbGridTemplateColumns / schGridTemplateColumnsstringExplicit template column sizes for the grid.
pcbGridTemplate / schGridTemplatestringShorthand template definition covering both rows and columns.
pcbGridGap / schGridGapnumber | stringSets the row and column gap simultaneously.
pcbGridRowGap / schGridRowGapnumber | stringSets the gap between rows.
pcbGridColumnGap / schGridColumnGapnumber | stringSets the gap between columns.

Flex Layout Props

export default () => (
<board width="26mm" height="20mm">
<group pcbFlex pcbFlexGap="1mm" pcbAlignItems="center" pcbJustifyContent="space-between">
<resistor name="R1" resistance="1k" footprint="0402" />
<resistor name="R2" resistance="1k" footprint="0402" />
<resistor name="R3" resistance="1k" footprint="0402" />
</group>
</board>
)
PCB Circuit Preview
PropTypeDescription
pcbFlex / schFlexboolean | stringEnables flex layout for PCB or schematic contents; string values pass raw CSS flex settings.
pcbFlexGap / schFlexGapnumber | stringGap between items in a flex layout.
pcbFlexDirection / schFlexDirection"row" | "column"Controls primary axis direction.
pcbAlignItems / schAlignItems"start" | "center" | "end" | "stretch"Aligns items on the cross axis.
pcbJustifyContent / schJustifyContent"start" | "center" | "end" | "stretch" | "space-between" | "space-around" | "space-evenly"Aligns items on the main axis.
pcbFlexRow / schFlexRowbooleanConvenience booleans for forcing row direction.
pcbFlexColumn / schFlexColumnbooleanConvenience booleans for forcing column direction.
pcbGap / schGapnumber | stringLegacy alias for flex gap sizing.
pcbPack / schPackbooleanEnables flexbox packing utilities.
pcbPackGapnumber | stringGap used when pcbPack is enabled.
schMatchAdaptbooleanIn schematic flex layouts, match the adaptive flex sizing of PCB contents.

Moving multiple components via a <group />

<group /> elements can be used to move multiple components at once.

In the example below every schematic symbol inside the <group /> will be moved 5mm to the right and 3mm up.

<group schX={5} schY={3}>
<resistor name="R1" resistance="1k" footprint="0402" />
<resistor name="R2" resistance="1k" footprint="0402" schY={2} />
<resistor name="R3" resistance="1k" footprint="0402" schY={2} />
</group>

We can similarly use a <group /> to move multiple PCB elements at once:

<group pcbX={5} pcbY={3}>
<resistor name="R1" resistance="1k" footprint="0402" />
<resistor name="R2" resistance="1k" footprint="0402" pcbY={2} />
<resistor name="R3" resistance="1k" footprint="0402" pcbY={2} />
</group>