@gluonjs/core / src/styles / StyleSheetSelection
Interface: StyleSheetSelection
Extended by
Properties
entries
readonlyentries: readonlyStyleSheetSelectionEntry[]
version
readonlyversion:1
Example
Carry one immutable ordered set of named stylesheet entries across installation and SSR boundaries:
import {
createStyleSheetOwner,
createStyleSheetSelection,
css,
getStyleSheetDigest,
getStyleTextDigest,
replaceStyleSheet,
type StyleSheetOwner,
type StyleSheetSelection,
type StyleSheetSelectionEntry,
} from '@gluonjs/core';
const sheet = css`:root { --shop-accent: blue; }`;
const entry = { id: 'shop-theme', scope: 'shop', sheet } satisfies StyleSheetSelectionEntry;
const selection: StyleSheetSelection = createStyleSheetSelection([entry]);
const owner: StyleSheetOwner = createStyleSheetOwner(document);
owner.retain(sheet);
replaceStyleSheet(sheet, ':root { --shop-accent: green; }');
console.log(selection.entries[0]?.id, getStyleSheetDigest(sheet), getStyleTextDigest('shop'));
owner.release(sheet);
owner.dispose();