guide
Runtime
How zRuntime scans the DOM, expands shorthands, compiles interactive utilities on demand, and prevents layout shift.
zRuntime is the client-side plugin engine that expands shorthand tokens, generates interactive CSS rules (:hover, :focus-visible, ::before, ::after, arbitrary [property]={value}), and injects @layer blocks into <style id="z-interactive-styles">.
| Hook / Method | Purpose |
|---|---|
window.zRuntime.debug = true | Enables per-plugin diagnostics ([zRuntime:<plugin>]) for missing variables or paired classes. |
window.zRuntime.safelist | Pre-compiles dynamic classes from strings or { class, states, prefixes, dark } objects. |
window.zRuntime.customRules | Adds new Rule definitions or replaces built-ins by matching selector. |
zRuntime.refresh() | Clears the internal rule cache and re-generates all styles. |
zRuntime.regenerate() | Re-scans and injects styles without clearing the rule cache. |
runtime/01-config.js
window.zRuntime = window.zRuntime || {};
// Enable per-plugin console diagnostics during development
window.zRuntime.debug = true;
// Pre-generate classes that are not in the initial DOM
window.zRuntime.safelist = [
'opacity:hover',
{
class: 'bg',
states: [':hover', ':focus-visible'],
prefixes: ['md', 'lg'],
dark: true,
},
];
// Add or override utility rules (applied via @layer)
window.zRuntime.customRules = [
{
selector: 'shadow-box',
properties: 'box-shadow',
values: ['0 0 0 __size__ __color__'],
placeholders: {
__size__: 'shadow-size',
__color__: 'shadow-color',
},
layer: 'utilities',
},
];
Execution runs through six built-in plugins in order: cls-prevention, custom-rules, inline-vars, dom-extractor, safelist, and arbitrary-properties. After injection, cls-prevention swaps z-not-ready to z-ready on document.documentElement and dispatches z-runtime:ready.