System block diagrams
Use system blocks to explain what a circuit does. This wireless sensor node collects measurements, processes them, and transmits them through a radio.
Describe the system
Start with a systemblock.page. Add a
systemblock.component for each
function, and use a systemblock.group
to collect related functions. Connect the blocks with
systemblock.connection elements
that name the interfaces between them.
import { systemblock } from "tscircuit"
export default () => (
<systemblock.page name="overview" displayName="Wireless sensor node" direction="down">
<systemblock.group name="processing" displayName="Sensing and processing">
<systemblock.component name="sensor" displayName="Environment sensor"
description="Measures temperature and humidity" />
<systemblock.component name="mcu" displayName="Microcontroller"
description="Processes readings" />
</systemblock.group>
<systemblock.component name="radio" displayName="Radio module"
description="Transmits measurements" />
<systemblock.connection from="sensor" to="mcu" label="I2C" direction="both" />
<systemblock.connection from="mcu" to="radio" label="SPI" direction="both" />
</systemblock.page>
)
Here, the sensor and microcontroller belong to the same subsystem. The I2C and
SPI connections have arrows at both ends to indicate two-way communication.
The page's direction="down" arranges the flow vertically. Core chooses block
sizes, positions, routes, and label positions automatically.
The preview is rendered from this TSX by svg.tscircuit.com using circuit-to-svg. Exported System
SVGs work independently of the editor's available tabs. Save the example as
system-blocks.circuit.tsx to use it in the export below.
Render an SVG
The tscircuit package re-exports the systemblock namespace from @tscircuit/core.
import { Circuit } from "tscircuit"
import { convertCircuitJsonToSystemSvg } from "circuit-to-svg"
import SystemOverview from "./system-blocks.circuit"
const circuit = new Circuit()
circuit.add(<SystemOverview />)
await circuit.renderUntilSettled()
const json = circuit.getCircuitJson()
const page = json.find((record) =>
record.type === "system_block_page" && record.name === "overview")
if (!page || page.type !== "system_block_page") throw new Error("Missing overview")
const svg = convertCircuitJsonToSystemSvg(json, {
systemBlockPageId: page.system_block_page_id,
width: 1000,
})
Omit systemBlockPageId to render the first page. The Circuit JSON records already
contain resolved geometry in diagram millimeters, centered on the page with +X
right and +Y up. Group membership does not introduce relative coordinates.
Connections store is_signal and is_power flags and label_anchor_center.