Themes

Chart themes style paper, ink, axes, type, and interaction chrome. Compose a declaration-only child under <GGPlot> — a named shell such as <ThemeMinimal />, or the generic <Theme name={…} /> escape hatch. Themes do not encode data colors; those come from palette schemes on color scales.

Visual portraits of every built-in live on the Themes showcase.

Components

Named shells fix the base theme. Every shell accepts the same optional role overrides as props (ink, paper, tooltipPaper, …). The generic <Theme> also accepts name for a reactive base.

PortableSpec nameSvelte componentNotes
(dynamic)ThemeEscape hatch: name + role overrides.
defaultThemeDefaultNamed base.
lightThemeLightNamed base.
darkThemeDarkNamed base.
minimalThemeMinimalNamed base.
ggplot2ThemeGgplot2Named base.
classicThemeClassicNamed base.
bwThemeBwNamed base.
hrbrThemeHrbrNamed base.
fewThemeFewNamed base.
cleanThemeCleanNamed base.
fivethirtyeightThemeFivethirtyeightNamed base.
economistThemeEconomistNamed base.
tufteThemeTufteNamed base.
linedrawThemeLinedrawNamed base.
voidThemeVoidNamed base.
stataThemeStataNamed base.
stata_s1colorThemeStatas1colorNamed base.
stata_monoThemeStatamonoNamed base.
solarizedThemeSolarizedNamed base.
solarizeddarkThemeSolarizeddarkNamed base.
economist_whiteThemeEconomistwhiteNamed base.
solarized_2ThemeSolarized2Named base.
solarized_2darkThemeSolarized2darkNamed base.
wsjThemeWsjNamed base.
gdocsThemeGdocsNamed base.
hcThemeHcNamed base.
hcdarkThemeHcdarkNamed base.
panderThemePanderNamed base.
calcThemeCalcNamed base.
excelThemeExcelNamed base.
excel_newThemeExcelnewNamed base.
baseThemeBaseNamed base.
igrayThemeIgrayNamed base.
mapThemeMapNamed base.
solidThemeSolidNamed base.
greyThemeGreyAlias of ggplot2 (same token map).
grayThemeGrayAlias of ggplot2 (same token map).
testThemeTestNamed base.

Usage

One theme child per plot. Composition is replace: if you declare two theme children, the last one wins. Role overrides merge onto the named base — unset roles keep the built-in values.

<script lang="ts">
  import { GeomPoint, GGPlot, ThemeDark } from "@ggsvelte/svelte";

  const rows = [
    { x: 1, y: 2 },
    { x: 2, y: 4 },
  ];
</script>

<GGPlot data={rows} aes={{ x: "x", y: "y" }}>
  <ThemeDark ink="#f5f5f5" tooltipPaper="#1a1a1a" tooltipInk="#f5f5f5" />
  <GeomPoint />
</GGPlot>

Reactive base name:

<Theme name={activeTheme} paper="none" focusRing="#ffcc00" />

Color and interaction roles

These props are CSS colors (or, for interactionMuted, a 0–1 opacity). Color roles ride --gg-* custom properties so a host can restyle without re-authoring the plot. Interaction roles also publish --gg-theme-* on the plot root for tool rails, tooltips, focus rings, and selection chrome — keep tooltipPaper / tooltipInk and interactionInk contrasty so recovery controls like legend Clear stay readable on dark bases.

PropKindAffectsCSS
inkcolorAxis lines, tick labels, titles, unmapped line/point/text marks, legend labels.--gg-ink
papercolorPlot-wide background. Use "none" for transparent.--gg-paper
accentcolorDefault fill for unmapped bars, columns, and areas.--gg-accent
gridcolorPanel major grid lines.--gg-grid
panelcolorPanel background (separate from paper).--gg-panel
letterboxFillcolorFixed-aspect gutter fill. Defaults to paper when unset.--gg-letterboxFill
axisTextcolorAxis tick-label color.--gg-axisText
axisLinecolorAxis baseline color.--gg-axisLine
tickColorcolorAxis tick-mark color.--gg-tickColor
panelBordercolorPanel frame color when showPanelBorder is true.--gg-panelBorder
interactionInkcolorPrimary interaction-control and overlay ink (tool rail, clear, overlays).--gg-interactionInk / --gg-theme-interactionInk
interactionMutedopacityOpacity for marks de-emphasized by legend focus or selection (0–1 number, not a color).--gg-interactionMuted / --gg-theme-interactionMuted (numeric alpha)
focusRingcolorKeyboard-focus and active-mark halo.--gg-focusRing / --gg-theme-focusRing
crosshaircolorCrosshair guide color.--gg-crosshair / --gg-theme-crosshair
selectionFillcolorInterval-selection fill (normally translucent).--gg-selectionFill / --gg-theme-selectionFill
selectionStrokecolorInterval-selection and zoom-target stroke.--gg-selectionStroke / --gg-theme-selectionStroke
tooltipPapercolorOpaque tooltip surface.--gg-tooltipPaper / --gg-theme-tooltipPaper
tooltipInkcolorTooltip foreground text.--gg-tooltipInk / --gg-theme-tooltipInk
tooltipBordercolorTooltip keyline.--gg-tooltipBorder / --gg-theme-tooltipBorder
toolActivecolorActive tool text and underline on the tool rail.--gg-toolActive / --gg-theme-toolActive

Type and geometry roles

Sizes are in CSS px unless noted. Boolean flags blank axis/grid pieces (void-style themes turn labels and grids off).

PropKindAffects
fontFamilytypeChart typeface stack.
fontSizelengthBase and tick-label size in px.
axisTextSizelengthAxis tick-label size in px.
fontWeightlengthBase font weight (1–1000).
titleSizelengthPlot title size in px.
titleWeightlengthPlot title weight.
subtitleSizelengthPlot subtitle size in px.
subtitleWeightlengthPlot subtitle weight.
axisTitleSizelengthAxis title size in px.
axisTitleWeightlengthAxis title weight.
guideTitleSizelengthLegend / guide title size in px.
legendKeySizelengthLegend swatch size in px.
legendKeyGaplengthGap between legend swatch and label.
legendRowGaplengthVertical gap between legend rows.
guideBlockGaplengthGap between stacked guide blocks.
colorbarThicknesslengthContinuous colorbar thickness in px.
colorbarLengthMinlengthMinimum colorbar length in px.
captionSizelengthCaption text size in px.
stripSizelengthFacet strip label size in px.
stripWeightlengthFacet strip label weight.
axisLineWidthlengthAxis baseline stroke width.
tickWidthlengthTick-mark stroke width.
tickLengthlengthTick-mark length in px.
gridWidthlengthGrid-line stroke width.
panelBorderWidthlengthPanel border stroke width.
gridDasharraydashSVG stroke-dasharray for major grid lines.
axisLineXbooleanDraw the x-axis baseline.
axisLineYbooleanDraw the y-axis baseline.
ticksXbooleanDraw x-axis ticks.
ticksYbooleanDraw y-axis ticks.
labelsXbooleanShow x-axis tick labels (false for theme_void-style blanking).
labelsYbooleanShow y-axis tick labels.
gridXbooleanDraw vertical grid lines.
gridYbooleanDraw horizontal grid lines.
showPanelBorderbooleanDraw the panel frame.

Safe overrides

  • Prefer typed theme props (<ThemeDark paper="#0b0b0b" />) when authoring in Svelte — values land in PortableSpec and stay edition-stable.
  • Host CSS on --gg-ink, --gg-paper, and the other --gg-* roles works without a re-render; only override roles you intend to change.
  • Never treat interactionMuted as a color — it is a numeric alpha applied to de-emphasized marks.
  • When you darken paper / panel, also set tooltipPaper, tooltipInk, interactionInk, and focusRing so inspect chrome and legend Clear keep contrast.
  • Themes style chrome only. Data series colors use named palette schemes on ScaleColor* / ScaleFill* children.

See also