Dynamic SVG (DSVG)
DSVG is an SVG-compatible document format for dynamic graphics. It adds:
- Yoga flexbox layout on SVG
<g>groups - Mustache variable interpolation in attributes and text
- Deterministic OpenType text measurement for flex
<text>children
A DSVG file remains valid SVG/XML. A compiler resolves templates, measures text from supplied fonts, applies layout, and emits ordinary static SVG.
Current version
- Specification: 0.1 (draft)
- TypeScript package:
@deckify/dsvg0.1.0(ESM-only) - License: Apache-2.0
Minimal example
<svg xmlns="http://www.w3.org/2000/svg" data-dsvg-version="0.1" width="300" height="100">
<g
data-dsvg-layout="flex"
data-dsvg-gap="16"
data-dsvg-width="300"
data-dsvg-height="100"
>
<rect width="40" height="40" fill="{{accent}}" />
<rect width="40" height="40" fill="#33cc66" />
</g>
</svg>
import { compileDsvg } from '@deckify/dsvg';
const { svg } = await compileDsvg(source, {
variables: { accent: '#3366ff' },
});
Compiled output: