1. The Configuration
Themes are defined insqueditor.config.js. Each theme entry controls how a specific set of pages is styled and packaged.
squeditor.config.js
Property Reference
| Property | Type | Description |
|---|---|---|
Theme Slug | string | The unique ID (key) for the theme (e.g., 'saas'). Used in URL parameters and internal mapping. |
label | string | The human-readable name. |
bodyClass | string | The CSS class applied to the <body> tag. All theme-specific SCSS variables are scoped to this class. |
scss | string | Path to the theme’s SCSS entry point. |
pages | array | List of .php files (relative to src/) that should default to this theme. Use '*' to match all. |
distSubfolder | string | (Optional) Subdirectory within dist/ where this theme’s static files will be saved during build, great for multi-purpose template. |
2. The Theme SCSS File
Each theme SCSS file uses thesq-theme mixin. This mixin automatically generates scoped CSS variables (--sq-*) for both light and dark modes, applied to your theme’s bodyClass.
src/assets/scss/themes/_saas.scss
Advanced Token Customization
Squeditor provides two maps for fine-grained token control:$overrides: Use this for tokens that should change globally for this theme (e.g., a “rounded” theme where everything hasbtn-radius: 50rem).$dark-overrides: Use this for tokens that specifically need adjustment in dark mode. For example, some fonts look thicker on dark backgrounds, so you might want to dropheading-font-weightfrom600(global) to400(dark only).
Why use Tokens vs. Manual CSS?
If you update @_base.scss (or the framework defaults) to use tokens:| Token Slug | CSS Property | Common Values |
|---|---|---|
heading-font-weight | font-weight | 300 (Light), 600 (Semi-Bold), 700 (Bold) |
heading-line-height | line-height | 1, 1.1, 1.2 |
heading-letter-spacing | letter-spacing | -0.02em, -0.05em |
btn-radius | border-radius | 0rem (Sharp), 0.5rem (Soft), 99rem (Pill) |
navbar-nav-gap | gap | 1rem (Compact), 2.5rem (Spacious) |
3. How It Works
** Token Override Mechanism ** Squeditor uses a “last-in-wins” approach. During the build process, the framework dynamically rewrites the last@import in your main.scss to target the active theme:
src/init.php based on:
- URL Query:
?theme=id(highest priority) - Page Mapping: Matches the current PHP file against the
pagesarray in your config. - Default: Falls back to the first theme in your config if no match is found.
Demo Mode & Theme Switcher
If$site['demo_mode'] = true is set in your configuration, the Theme Switcher UI will appear. This allows users to manually cycle through your defined palettes and typography presets in the browser, overriding the default theme via query parameters and localStorage.
Playground: Common Scenarios
** Scenario A: Single Niche, Multiple Visual Styles ** Use this when building one template (e.g., a Portfolio) that you want to offer in multiple “flavors” (Clean, Bold, Pastel). All versions share the same pages.dist/ structure:
dist/medical-demo/index.html(Styled with Medical theme)dist/saas-demo/index.html(Styled with SaaS theme)