StyletronClient

StyletronClient

A Styletron class for rendering styles in the browser

Constructor

new StyletronClient(serverStylesopt, optsopt)

Source:

Create a new StyletronClient instance

Example
const elements = document.getElementsByClassName('_styletron_hydrate_');
const styletron = new StyletronClient(elements);
Parameters:
Name Type Attributes Description
serverStyles NodeList | HTMLCollection | Array.<HTMLStyleElement> <optional>

List of server style elements

opts object <optional>

StyletronCore options

Extends

Methods

injectDeclaration() → {string}

Source:
Overrides:

Inject declaration into the stylesheet and return the unique class name

Example
// <style id="styletron">.a{color:red}</style>
const styletron = new StyletronClient(document.getElementsByClassName('_styletron_hydrate_'));
styletron.injectDeclaration({prop: 'color', val: 'blue'});
// → 'b'
styletron.injectDeclaration({prop: 'color', val: 'red', media: '(min-width: 800px)'});
// → 'c'
styletron.injectDeclaration({prop: 'color', val: 'red'});
// → 'a'
Returns:

class name

Type
string