@ggts-sh/svelte
Svelte 5 components for ggts. Re-exports @ggts-sh/spec and
@ggts-sh/core. The agent skill ships separately as
@ggts-sh/skill, and the
ggts render CLI as
@ggts-sh/cli — install both in
every sandbox where an agent authors specs.
bun add @ggts-sh/svelte @ggts-sh/core
# or: npm install @ggts-sh/svelte @ggts-sh/core
Requires Node.js 22+ and Svelte 5.33.1+. The example imports bundled data
from @ggts-sh/core/data, so it installs core as a direct dependency.
Charts with inline data need only @ggts-sh/svelte.
Example
Compose with declaration-only children (theme, scales, labs, geoms). Do not put
theme, scales, labs, guides, facet, coord, or legend on
<GGPlot> — those props were removed in 0.13.0.
<script lang="ts">
import {
GeomPoint,
GeomSmooth,
GGPlot,
Labs,
ThemeMinimal,
} from "@ggts-sh/svelte";
import { kyotoSakura } from "@ggts-sh/core/data";
</script>
<GGPlot data={kyotoSakura} aes={{ x: "year", y: "bloomDoy" }}>
<GeomSmooth method="loess" se={false} />
<GeomPoint size={2} alpha={0.7} />
<ThemeMinimal />
<Labs
title="Kyoto cherry blossom full-bloom dates, 812–2026"
subtitle="Full bloom moved about ten days earlier after the industrial era"
x="Year"
y="Day of year"
/>
</GGPlot>
Convention (ggplot2 thinking order): mark layers first, then scales / coords /
facets, then theme / guides / labs, then host-only <Inspect> last. Dense
points may render on canvas; axes, legends, text, and accessible descriptions
stay in the DOM. Prefer <Inspect /> and <GuideLegend channel focus> /
<GuideLegend channel filter> for interaction — not plot-level inspect,
legendFocus, or legendFilter.
Smaller bundles: the lean entry
@ggts-sh/svelte registers the basic geoms, stats, and color and style
scale kinds when you import it. To ship only what your charts use, import
from @ggts-sh/svelte/lean and call the register functions once at startup:
<script lang="ts" module>
import {
registerBasicLines,
registerBasicPoints,
registerDefaultOrdinalColor,
} from "@ggts-sh/svelte/lean";
registerBasicPoints();
registerBasicLines();
registerDefaultOrdinalColor();
</script>
<script lang="ts">
import { GeomLine, GeomPoint, GGPlot } from "@ggts-sh/svelte/lean";
</script>
For a point and line chart with mapped color, this saves about 26 KB gzip.
If a chart needs a family that is not registered, GGPlot throws an error
that names the register function to call. One import from @ggts-sh/svelte
anywhere in the app brings back the full basic registration.
Agent skill
Published separately as
@ggts-sh/skill:
node_modules/@ggts-sh/skill/SKILL.md. Copy it into your agent's skills
directory as ggts/ and re-copy on version bumps — dependabot surfaces
those. (Removed from this package in 0.27.0.)
Emit PortableSpec JSON, run validate(), apply fix.example at path,
re-validate, then render with <GGPlot spec={…} />, renderToSVGString, or
ggts render. Schema: schema/v0.json.
Migrating old code
If you still have pre-0.13 sources with grammar props on <GGPlot>, the
codemod rewrites them to children:
npm exec --package=@ggts-sh/svelte -- ggts-codemod src # show what would change
npm exec --package=@ggts-sh/svelte -- ggts-codemod --write src # apply
Shapes it will not rewrite mechanically are printed as manual change required with a link to the upgrading
guide, never half-migrated.
Links
Pre-1.0. Lifecycle and compatibility contracts are on the docs site.
MIT © Liam O'Dea