Skip to main content
tscircuit Essentials

Restyling Schematics with CSS Classes

Generated schematic SVGs expose a small set of stable CSS classes for restyling. Use these classes when you want to override schematic colors, stroke widths, labels, traces, ports, or annotation shapes.

Avoid styling older generic classes such as component, chip, pin-number, or trace directly. They can appear in the SVG for compatibility, but the supported override surface is the tscircuit-schematic root class and the sch-* classes listed below.

Adding CSS in RunFrame

Pass schematicSvgOptions to <RunFrame /> to provide the className and css options used when RunFrame renders the schematic SVG.

import { RunFrame } from "@tscircuit/runframe"

export default () => (
<RunFrame
fsMap={{
"main.tsx": `
circuit.add(
<board width="10mm" height="10mm">
<resistor name="R1" resistance="1k" footprint="0402" />
<capacitor name="C1" capacitance="1uF" footprint="0603" pcbX={4} />
<trace from=".R1 .pin1" to=".C1 .pin1" />
</board>
)
`,
}}
entrypoint="main.tsx"
schematicSvgOptions={{
className: "datasheet-theme",
css: `
.tscircuit-schematic.datasheet-theme .sch-component-body {
fill: #eef2ff;
stroke: #4338ca;
}

.tscircuit-schematic.datasheet-theme .sch-trace-path,
.tscircuit-schematic.datasheet-theme .sch-port-line {
stroke: #0f766e;
stroke-width: 2px;
}

.tscircuit-schematic.datasheet-theme .sch-component-name,
.tscircuit-schematic.datasheet-theme .sch-pin-label,
.tscircuit-schematic.datasheet-theme .sch-pin-number {
fill: #111827;
font-weight: 600;
}
`,
}}
/>
)

Scope your rules with a custom root class when possible. This keeps schematic styling from leaking into other SVGs on the page.

Supported Classes

Root

ClassElement
tscircuit-schematicRoot schematic <svg>
Custom classNameExtra root class supplied through render options

Components

ClassElement
sch-componentComponent group
sch-component-bodyBox-style component body
sch-component-overlayTransparent component hover or selection overlay
sch-component-nameReference designator text
sch-component-textText inside a symbol-style component
sch-component-symbol-pathSymbol path segment
sch-component-symbol-boxSymbol box segment
sch-component-symbol-circleSymbol circle segment

Ports and Pins

ClassElement
sch-portPort group
sch-port-hoverPort hover target group
sch-component-pinGeneric pin geometry
sch-port-lineLine from component body to port terminal
sch-port-terminalPort terminal marker
sch-port-indicatorStandalone port indicator marker
sch-port-labelStandalone port indicator label
sch-inversion-bubbleInversion bubble on a port
sch-pin-labelPin label text
sch-pin-numberPin number text

Traces

ClassElement
sch-traceTrace group
sch-trace-overlaysTrace overlay group
sch-trace-pathVisible trace path
sch-trace-hitboxInvisible hover outline around a trace
sch-trace-junctionJunction dot
sch-trace-crossing-outlineBackground outline used at a crossing
sch-trace-crossing-pathVisible crossing arc

Net Labels

ClassElement
sch-net-labelNet label shape
sch-net-label-textNet label text
sch-net-label-overlayNet label overlay rectangle
sch-net-label-symbol-pathSymbol-style net label path
sch-net-label-symbol-textSymbol-style net label text
sch-net-label-symbol-boxSymbol-style net label box
sch-net-label-symbol-circleSymbol-style net label circle

Schematic Shapes and Text

ClassElement
sch-lineSchematic line
sch-pathSchematic path
sch-rectSchematic rectangle
sch-boxSchematic box
sch-circleSchematic circle
sch-arcSchematic arc
sch-textSchematic text

Tables, Probes, and Helpers

ClassElement
sch-tableSchematic table group
sch-table-borderTable border
sch-table-grid-lineTable grid line
sch-table-textTable cell text
sch-voltage-probeVoltage probe arrow
sch-voltage-probe-labelVoltage probe label
sch-gridOptional schematic grid group
sch-labeled-pointsOptional labeled points group