<s:callout><s:scale-bar><s:arrow>svg overlay
Note
s:s:
Namespace
s:<svg>
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:callout x="300" y="150" label="Hello, components!" shape="pill"/>
</svg>
```
A figure annotated with a single overlay component.
:::

Figure 1:
How it works
svg overlay
Scans for <s:anchor>definitions and generates auto-anchors from the viewBoxExpands every <s:*>element into standard SVG (text, paths, shapes) Detects references to built-in definitions (arrowheads, marker symbols) and injects only the ones actually used Stores the compiled SVG separately — your source is preserved unchanged
s:
Component reference
Overview
<s:arrow> | ||
<s:callout><s:badge> | ||
<s:scale-bar><s:dimension><s:angle> | ||
<s:brace><s:bracket> | ||
<s:roi-rect><s:roi-ellipse><s:roi-polygon><s:spotlight> | ||
<s:marker><s:crosshair> | ||
<s:halo> | ||
<s:compass> | ||
<s:anchor> |
Common attributes
Positioning
xy | |
at | at="#peak"at="#s:bottom-left" |
from | from="#peak" |
dxdy | |
to | |
to-xto-y |
<s:marker><s:compass><s:halo>at<s:arrow><s:brace>fromto
Colors
strokefilltextcolorcurrentColorwhitecurrentColorcurrentColor
stroke | color | currentColor | |
fill | color | ||
text | color | currentColor | |
color | currentColor |
<s:arrow x="100" y="100" to-x="300" to-y="200" stroke="crimson"/>
<s:callout x="300" y="160" label="n = 1,024" shape="pill" fill="#e8f4fd" stroke="#4a90d9" text="#1a5276"/>
<s:marker at="#peak" symbol="circle" color="#2563eb"/>
<s:dimension x="50" y="200" to-x="250" to-y="200" label="4.2 cm" stroke="gray" text="navy"/>Labels
label | ||
label-position | abovebelowleftrightcenter |
Connectors
curve | straightquadcubicelbow | straight | |
corner | horizontal-firstvertical-first | horizontal-first | curve="elbow" |
tip | endstartbothnone | end | |
tip-style | #s:arrow-* | s:arrow-closed |
SVG pass-through
stroke-widthopacityfont-sizestroke-dasharray
<s:arrow x="100" y="100" to-x="300" to-y="200" stroke="crimson" stroke-width="3"/>Built-in definitions
Arrow markers
tip-style<s:arrow><s:callout>marker-endmarker-start
s:arrow-closed | |
s:arrow-open | |
s:arrow-dot | |
s:cap-line | <s:dimension> |
Marker symbols
symbol<s:marker><use href="#s:marker-*">
s:marker-circle | |
s:marker-cross | |
s:marker-diamond | |
s:marker-pin | |
s:marker-plus | |
s:marker-square | |
s:marker-star | |
s:marker-triangle | |
s:marker-triangle-down |
url(#id)href="#id"
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns="http://www.w3.org/2000/svg">
<line x1="100" y1="250" x2="300" y2="50" marker-end="url(#s:arrow-closed)"/>
<text x="310" y="45">Using a built-in arrowhead</text>
</svg>
```
A standard SVG line using a built-in arrowhead definition — no component needed, just the `url(#s:arrow-closed)` reference.
:::

Figure 2: url(#s:arrow-closed)
Anchors and positioning
Named anchors
<s:anchor>fromtodxdy
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="feature" x="200" y="120"/>
<s:callout from="#feature" dx="150" dy="-60" label="Important" to="#feature"/>
<s:roi-rect from="#feature" dx="-40" dy="-30" to-x="260" to-y="170" stroke-style="dashed"/>
</svg>
```
An anchor at (200, 120) referenced by a callout and a dashed ROI rectangle. The callout label is offset 150px right and 60px up from the anchor; its leader line points back to the anchor.
:::

Figure 3:
Auto-anchors
viewBox<s:anchor>
#s:center | |
#s:origin#s:top-left | |
#s:top-right | |
#s:bottom-left | |
#s:bottom-right | |
#s:top-center | |
#s:bottom-center | |
#s:mid-left | |
#s:mid-right |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:callout from="#s:center" label="Center" shape="pill"/>
<s:badge from="#s:top-left" dx="40" dy="30" label="A"/>
<s:badge from="#s:top-right" dx="-40" dy="30" label="B"/>
</svg>
```
Auto-anchors in action: a callout at the center and badges near the top corners, all positioned relative to viewBox-derived anchors.
:::

Figure 4:
Arrows & connectors
<s:arrow>
xyfromto-xto-yto
xy | |||
from | |||
to-xto-y | |||
to | |||
dxdy | 0 | ||
curve | straightquadcubicelbow | straight | |
corner | horizontal-firstvertical-first | horizontal-first | |
tip | endstartbothnone | end | |
tip-style | s:arrow-closed | ||
label | |||
label-position | abovebelow | above | |
label-angle | alonghorizontalvertical | along | alonghorizontalvertical |
Straight arrows
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:arrow x="80" y="60" to-x="250" to-y="180" label="Default"/>
<s:arrow x="280" y="240" to-x="450" to-y="80" tip="both" label="Both tips"/>
<s:arrow x="460" y="240" to-x="560" to-y="60" tip-style="s:arrow-open" label="Open"/>
</svg>
```
Three straight arrows: default single arrowhead, double-ended, and open chevron style.
:::

Figure 5:
Curved arrows
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:arrow x="50" y="250" to-x="200" to-y="50" curve="quad" label="Quadratic"/>
<s:arrow x="230" y="250" to-x="380" to-y="50" curve="cubic" label="Cubic"/>
<s:arrow x="420" y="80" to-x="560" to-y="240" curve="elbow" label="Elbow"/>
</svg>
```
Three curve types: quadratic Bézier, cubic Bézier, and right-angle elbow connector.
:::

Figure 6:
Elbow corners
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:arrow x="80" y="60" to-x="280" to-y="240" curve="elbow" corner="horizontal-first" label="H-first"/>
<s:arrow x="350" y="60" to-x="550" to-y="240" curve="elbow" corner="vertical-first" label="V-first"/>
</svg>
```
Elbow connectors: `horizontal-first` bends horizontal then vertical; `vertical-first` bends vertical then horizontal.
:::

Figure 7: horizontal-firstvertical-first
Labels & callouts
Callout
<s:callout>
xyfromlabel
xy | |||
from | |||
dxdy | 0 | ||
label | |||
shape | nonerectpillcircle | none | |
toto-xto-y | |||
tip-style | s:arrow-closed | ||
curve | straightquadcubicelbow | straight |
Standalone labels and shapes
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:callout x="100" y="60" label="Plain text"/>
<s:callout x="300" y="60" label="Rectangle" shape="rect"/>
<s:callout x="500" y="60" label="Pill shape" shape="pill"/>
<s:callout x="300" y="160" label="n = 1,024" shape="pill" fill="#e8f4fd" stroke="#4a90d9" text="#1a5276"/>
</svg>
```
Callouts without leader lines: plain text, rectangle background, pill background, and a styled pill with custom fill, stroke, and text colors.
:::

Figure 8:
Callouts with leader lines
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="spot" x="150" y="200"/>
<s:callout from="#spot" dx="120" dy="-120" label="Feature A" to="#spot"/>
<s:callout x="450" y="50" label="Peak" to-x="350" to-y="180" shape="rect" curve="quad"/>
</svg>
```
Two callouts with leader lines: one using an anchor reference, another with direct coordinates and a quadratic curve.
:::

Figure 9:
Badge
<s:badge>
xyfromlabel
xy | |||
from | |||
dxdy | 0 | ||
label |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:badge from="#s:top-left" dx="30" dy="25" label="GFP"/>
<s:badge x="300" y="150" label="Ch2"/>
<s:badge from="#s:bottom-right" dx="-60" dy="-35" label="DAPI"/>
</svg>
```
Three badges using a mix of auto-anchor and direct coordinate positioning: a fluorescence channel name, a short identifier, and a stain label.
:::

Figure 10:
Tip
<s:badge><s:callout>
Measurement & scale
Scale bar
<s:scale-bar>
xyatlength
xy | |||
at | |||
dxdy | 0 | ||
length | |||
label | |||
label-position | abovebelow | below | |
side | bottomtopleftright | bottom | leftright |
Horizontal scale bar
::: figure {pad="0 0 56 0"}

```svg overlay
<svg viewBox="0 0 600 356" xmlns:s="https://stencila.io/svg">
<s:scale-bar at="#s:bottom-left" dx="40" dy="-30" length="130" label="20 μm"/>
</svg>
```
A microscopy-style scale bar positioned relative to the bottom-left auto-anchor using bottom padding.
:::

Figure 11:
Scale bar variations
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:scale-bar x="40" y="270" length="150" label="50 μm"/>
<s:scale-bar x="300" y="270" length="150" label="100 nm" label-position="above"/>
<s:scale-bar x="560" y="40" length="200" label="1 mm" side="right"/>
</svg>
```
Three scale bars: default (label below), label above, and a vertical bar on the right.
:::

Figure 12:
Dimension line
<s:dimension>
sidefromtoaboveabove<s:bracket><s:brace>
xyfromto-xto-yto
xy | |||
from | |||
to-xto-y | |||
to | |||
label | |||
label-position | abovebelow | above | |
label-angle | alonghorizontalvertical | along | alonghorizontalvertical |
side | abovebelowleftright | above | |
background | none | none |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:dimension x="100" y="100" to-x="400" to-y="100" label="30 cm" side="above"/>
<s:dimension x="450" y="60" to-x="450" to-y="240" label="18 cm" side="below"/>
</svg>
```
Horizontal and vertical dimension lines showing measured extents with perpendicular end bars.
:::

Figure 13:
Angle arc
<s:angle>
xyatfromto
xy | |||
at | |||
from | |||
from-xfrom-y | |||
toto-xto-y | |||
r | 30 | ||
label |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="vertex" x="200" y="240"/>
<s:anchor id="ray1" x="450" y="240"/>
<s:anchor id="ray2" x="350" y="60"/>
<!-- Draw the ray lines for context -->
<line x1="200" y1="240" x2="450" y2="240" stroke="currentColor" stroke-dasharray="4 3"/>
<line x1="200" y1="240" x2="350" y2="60" stroke="currentColor" stroke-dasharray="4 3"/>
<!-- Angle arc with label -->
<s:angle from="#ray1" to="#ray2" x="200" y="240" r="50" label="θ"/>
</svg>
```
An angle arc showing the angle between two rays from a vertex, with dashed reference lines drawn in raw SVG.
:::

Figure 14:
Brackets & braces
Brackets
<s:bracket>p < 0.05
xyfromto-xto-yto
xy | |||
from | |||
to-xto-y | |||
to | |||
side | abovebelowleftright | above | |
depth | |||
variant | squareround | square | |
label |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:bracket x="80" y="120" to-x="260" to-y="120" side="above" label="Group A"/>
<s:bracket x="300" y="120" to-x="520" to-y="120" side="above" variant="round" label="Group B"/>
<s:bracket x="180" y="200" to-x="420" to-y="200" side="below" label="p < 0.05"/>
</svg>
```
Three bracket variants: a square bracket above, a round bracket above, and a square bracket below with a significance label.
:::

Figure 15:
Braces
<s:brace>
xyfromto-xto-yto
xy | |||
from | |||
to-xto-y | |||
to | |||
side | abovebelowleftright | above | |
bulge | |||
label |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:brace x="100" y="60" to-x="100" to-y="260" side="left" label="Range A"/>
<s:brace x="200" y="100" to-x="400" to-y="100" side="above" label="Group A"/>
<s:brace x="200" y="200" to-x="400" to-y="200" side="below" label="Group B"/>
<s:brace x="500" y="60" to-x="500" to-y="260" side="right" label="Range B"/>
</svg>
```
Curly braces: above (Group A), below (Group B), on the left (Range A), and on the right (Range B).
:::

Figure 16:
Region of interest
ROI rectangle
<s:roi-rect>
xywidthheightfromto
xy | |||
widthheight | 50 | ||
fromto | |||
label | |||
label-position | abovebelowcenterleftright | above | |
stroke-style | soliddasheddotted | solid |
ROI ellipse
<s:roi-ellipse>
cxcyatrxry
cxcy | |||
at | |||
dxdy | 0 | ||
rxry | |||
label | |||
label-position | abovebelowcenterleftright | above | |
stroke-style | soliddasheddotted | solid |
Highlighting regions
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:roi-rect x="50" y="40" width="160" height="100" label="Region A" stroke-style="dashed" color="green"/>
<s:roi-rect x="350" y="160" width="120" height="90" label="Region B" label-position="below" stroke-style="dotted"/>
<s:roi-ellipse at="#s:center" rx="80" ry="50" label="Zone C"/>
</svg>
```
Two ROI rectangles with different stroke styles and label positions, and an elliptical region centered with the `#s:center` auto-anchor.
:::

Figure 17: #s:center
Using anchors for ROI bounds
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="tl" x="180" y="70"/>
<s:anchor id="br" x="420" y="230"/>
<s:roi-rect from="#tl" to="#br" label="Selection" stroke-style="dashed"/>
<s:marker at="#tl" symbol="cross" size="14"/>
<s:marker at="#br" symbol="cross" size="14"/>
</svg>
```
An ROI rectangle defined by two anchor points with `from`/`to`, and cross markers at each corner using `at` — no coordinate duplication.
:::

Figure 18: fromtoat
ROI polygon
<s:roi-polygon>
points
points | x,y"100,50 200,80 150,180" | ||
label | |||
label-position | abovebelowcenterleftright | above | |
stroke-style | soliddasheddotted | solid |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:roi-polygon points="100,60 250,40 300,120 220,200 80,160" label="Tissue boundary" stroke-style="dashed"/>
<s:roi-polygon points="350,80 480,60 520,180 430,240 330,200" label="Region B" stroke="crimson"/>
</svg>
```
Two polygon ROIs: a dashed tissue boundary and a solid region in crimson, each defined by a list of vertex coordinates.
:::

Figure 19:
Spotlight
<s:spotlight><mask>
cxcyat
cxcy | |||
at | |||
dxdy | 0 | ||
r | 50 | ||
rxry | r | ||
shape | circlerect | circle | |
widthheight | 100 | ||
opacity | 0.01.0 | 0.6 |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="feature" x="200" y="150"/>
<s:spotlight at="#feature" r="70"/>
<s:callout x="400" y="60" label="Feature of interest" to="#feature" shape="rect"/>
</svg>
```
A circular spotlight positioned with an anchor dims the surrounding area, with a callout pointing to the same anchor.
:::

Figure 20:
Point markers
Marker
<s:marker>
xyat
xy | |||
at | |||
dxdy | 0 | ||
symbol | circlecrossdiamondpinplussquarestartriangletriangle-down | circle | |
size | 20 | ||
color | currentColor | ||
fill | currentColor | color | |
stroke | currentColor | color | |
background | none | white | |
label | |||
label-position | rightabovebelowleft | right |
Tip
fill="none"
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<!-- Filled markers using auto-anchors -->
<s:marker at="#s:top-left" dx="60" dy="60" symbol="circle" label="circle" label-position="above" color="#2563eb"/>
<s:marker at="#s:top-center" dx="-60" dy="60" symbol="square" label="square" label-position="above" color="#2563eb"/>
<s:marker at="#s:top-center" dx="60" dy="60" symbol="diamond" label="diamond" label-position="above" color="#2563eb"/>
<s:marker at="#s:top-right" dx="-60" dy="60" symbol="triangle" label="triangle" label-position="above" color="#2563eb"/>
<!-- Open (outline) variants using auto-anchors -->
<s:marker at="#s:mid-left" dx="60" dy="40" symbol="star" label="star (open)" label-position="below" fill="none" color="#dc2626"/>
<s:marker at="#s:center" dx="-60" dy="40" symbol="triangle-down" label="triangle-down (open)" label-position="below" fill="none" color="#dc2626"/>
<!-- Stroke-only symbols and pin using x/y -->
<s:marker x="420" y="190" symbol="cross" label="cross" color="#16a34a"/>
<s:marker x="520" y="190" symbol="plus" label="plus" color="#16a34a"/>
<s:marker at="#s:bottom-center" dy="-30" symbol="pin" label="pin" label-position="left" color="#9333ea" size="24"/>
</svg>
```
All nine marker symbols. Top row: filled markers in blue. Middle row: open (outline) variants using `fill="none"`. Bottom: stroke-only symbols (cross, plus) and a pin.
:::

Figure 21: fill="none"
Crosshair
<s:crosshair>
cxcyat
cxcy | |||
at | |||
dxdy | 0 | ||
size | 20 | ||
gap | 4 | ||
ring | truefalse | false | |
label | |||
label-position | rightabovebelowleft | right |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:crosshair cx="150" cy="150" size="25" gap="5" label="Point A"/>
<s:crosshair at="#s:center" size="30" gap="6" ring="true" label="Center target" stroke="crimson" text="darkred"/>
</svg>
```
Two crosshairs: a basic reticle with direct coordinates, and a ringed crosshair positioned at the center auto-anchor.
:::

Figure 22:
Emphasis & focus
Halo
<s:halo>
cxcyat
cxcy | |||
at | |||
dxdy | 0 | ||
r | 15 | ||
width | 8 | ||
color | currentColor | ||
opacity | 0.01.0 | 0.4 |
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="site-a" x="150" y="150"/>
<s:anchor id="site-b" x="420" y="180"/>
<s:halo at="#site-a" r="20" width="10" color="gold" opacity="0.5"/>
<s:marker at="#site-a" symbol="circle" size="12"/>
<s:callout x="250" y="100" label="Active site" to="#site-a"/>
<s:halo at="#site-b" r="25" width="12" color="crimson" opacity="0.3"/>
<s:marker at="#site-b" symbol="star" size="16"/>
</svg>
```
Anchors eliminate coordinate duplication: each halo and marker pair references the same anchor, so moving a point means changing one `<s:anchor>` instead of two components.
:::

Figure 23: <s:anchor>
Orientation & reference
<s:compass>arrowfull
xyat
xy | |||
at | |||
dxdy | 0 | ||
size | 50 | ||
variant | arrowfull | arrow | |
axes | N/S E/W | "A/P D/V" |
axes"primary-pos/primary-neg secondary-pos/secondary-neg"/
axes | ||
|---|---|---|
N/S E/W | ||
A/P D/V | ||
L/R S/I |
Arrow variant (default)
arrow
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:compass at="#s:bottom-left" dx="60" dy="-50" size="50"/>
<s:callout x="100" y="270" label="Geographic north arrow" shape="none"/>
</svg>
```
A compass positioned with the `#s:bottom-left` auto-anchor, showing a north indicator.
:::

Figure 24: #s:bottom-left
Full variant with custom axes
full
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:compass at="#s:bottom-left" dx="80" dy="-60" size="50" variant="full" axes="A/P D/V"/>
<s:callout x="160" y="270" label="Anatomical axes" shape="none"/>
<s:compass at="#s:bottom-right" dx="-100" dy="-60" size="50" variant="full"/>
<s:callout x="500" y="195" label="Cardinal" shape="none"/>
</svg>
```
Full compass variants: anatomical axes (A/P, D/V) on the left and default cardinal directions (N/S, E/W) on the right.
:::

Figure 25:
Mixing components with raw SVG
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:anchor id="target" x="300" y="150"/>
<!-- Raw SVG for a custom shape -->
<rect x="240" y="100" width="120" height="100" rx="12" fill="none" stroke="currentColor" stroke-dasharray="6 3"/>
<!-- Component callout pointing at the custom shape -->
<s:callout x="480" y="50" label="Custom region" to="#target" shape="rect" curve="quad"/>
<!-- Component scale bar using auto-anchor -->
<s:scale-bar at="#s:bottom-left" dx="30" dy="-30" length="100" label="10 mm"/>
<!-- Component badge -->
<s:badge x="300" y="30" label="①"/>
</svg>
```
Raw SVG (dashed rounded rectangle) combined with overlay components (callout, scale bar, badge) in the same overlay.
:::

Figure 26:
Comprehensive example
::: figure {pad="0 0 46 0"}

```svg overlay
<svg viewBox="0 0 600 346" xmlns:s="https://stencila.io/svg">
<!-- Named anchors for key features -->
<s:anchor id="peak" x="250" y="80"/>
<s:anchor id="valley" x="420" y="200"/>
<!-- Region of interest -->
<s:roi-rect x="180" y="50" width="160" height="80" label="Primary ROI" stroke-style="dashed"/>
<!-- Callout with leader line -->
<s:callout from="#valley" dx="100" dy="-100" label="Local minimum" to="#valley" shape="rect"/>
<!-- Arrow connecting features -->
<s:arrow from="#peak" to="#valley" curve="quad" label="Transition" tip="both" stroke-width="1.5"/>
<!-- Halo and marker at anchors — no coordinate duplication -->
<s:halo at="#peak" r="10" width="6" color="gold" opacity="0.5"/>
<s:halo at="#valley" r="10" width="6" color="red" opacity="0.5"/>
<s:marker at="#peak" symbol="circle" size="12"/>
<s:marker at="#valley" symbol="circle" size="12"/>
<!-- Brace -->
<s:brace x="180" y="230" to-x="340" to-y="230" side="below" label="Observed range"/>
<!-- Scale bar and compass positioned via auto-anchors -->
<s:scale-bar at="#s:bottom-left" dx="40" dy="-26" length="130" label="20 μm"/>
<s:compass at="#s:bottom-right" dx="-40" dy="-26" size="36"/>
</svg>
```
A comprehensive annotation using `at` anchors: halos and markers reference named anchors (no coordinate duplication), while the scale bar and compass use auto-anchors for consistent bottom-edge placement.
:::

Figure 27: at