Theme Settings
Theme settings are typically applied like this:- Define defaults in
theme.config.ts - Fetch published overrides for a shop
- Merge overrides into defaults
- Apply settings to your UI (often via CSS variables)
Your theme decides how to apply settings. A common approach is CSS variables so the whole UI updates consistently.
Flow
Defaults + Published Overrides
This example uses helpers from@shoppex/sdk:
Apply A Setting (Simple Example)
If you use CSS variables, you can apply a color like this:CSS Variable Mapping (Reference Theme)
The reference theme maps settings to CSS variables as follows. Your theme can use different variable names — this is just how the built-in default theme does it.| Setting Path | CSS Variable | Transform |
|---|---|---|
colors.background | --surface | hexToRgb |
colors.surface | --card-bg | hexToRgb |
colors.primary | --brand-600 | hexToRgb |
colors.primaryDark | --brand-700 | hexToRgb (fallback: colors.secondary, then darken primary 10%) |
colors.text | --text | hexToRgb |
colors.textMuted | --text-muted | hexToRgb |
colors.textContrast | --text-contrast | hexToRgb |
colors.border | --border | hexToRgb |
colors.muted | --muted | hexToRgb |
colors.accent | --accent | hexToRgb |
colors.hover | --hover | hexToRgb |
colors.success | --success | hexToRgb |
colors.error | --destructive | hexToRgb |
typography.fontFamily | --font-family-body | direct string (also fallback for --font-family-heading) |
typography.headingFont | --font-family-heading | direct string (falls back to typography.fontFamily) |
typography.fontSize | --font-size-base | append px |
effects.borderRadius | --radius | value / 16 + rem |
buttons.borderRadius | --button-radius | append px |
header.height | --header-height | append px |
inputs.height | --input-height | append px |
inputs.borderRadius | --input-border-radius | append px |
This mapping is from the reference theme. Your theme can use different variable names.
Next Steps
Build Pipeline
How settings can be injected as initial data during build (optional).
React Reference
See a full working theme in this repo.
Sources
Reference implementation:themes/default/src/context/ThemeSettingsContext.tsxthemes/default/src/lib/cssVars.ts