xPulse
πŸ‡¬πŸ‡§ EN

Guide

Installation

npm install @xpulse/theme --registry=https://npm.xpulse.one

Usage

When @xpulse/theme is installed and started by @xpulse/app, a single minified CSS bundle is served at /_theme/css/xpulse.css. All themes (dark, light, and any app overrides) are included in that one file.

Recommended β€” use template methods in your layout:

{% themeAssets() %}

This renders the bundle link, the anti-FOUC inline script, and the browser runtime script. Add the switcher separately if needed:

{% themeSwitcher() %}

JavaScript

@xpulse/theme works without any required runtime JavaScript. Most use cases rely only on:

JavaScript is only needed as an optional behavior layer, for example:

What The Package Provides

Using A Custom App Theme

Create a file in your app under src/themes/:

/* src/themes/app.css */
.xpulse-shell {
width: min(1100px, calc(100% - 32px));
margin: 32px auto;
}

Important:

Theme Switcher

{% themeAssets() %}
{% themeSwitcher() %}

theme.allow and theme.default in xpulse.json control the switcher:

{
"theme": {
"default": "dark",
"allow": ["dark", "light"]
}
}
allow Result
[] or not set All discovered themes are allowed
["dark", "light"] Compact moon/sun toggle button
["dark", "light", "high-contrast"] Select dropdown
["dark"] No switcher rendered

Caching

The CSS bundle is cached at var/cache/theme/xpulse.css on first start and read directly from there on subsequent starts.

{
"theme": {
"cache": {
"enabled": true,
"ttl": 0
}
}
}

ttl: 0 means no expiry. ttl: 3600 invalidates the cache after 1 hour.

Component Class Naming

CSS classes from @xpulse/theme follow the xpulse-* prefix and BEM:

Related CSS variables use the --xpulse-* prefix.

en/guide.md 2026-03-26