Skip to content

Styling

Brandon Jordan edited this page Sep 11, 2024 · 5 revisions

Convert object to CSS

Spark provides a function that will turn an object of CSS rules, where the key is the selector and the value is an object containing properties with values, into a CSS string.

obj2CSS({"input":{"color":"green"}}); // Result: input{color:green;}

Apply styles to element

This function allows for the application of CSS properties to an HTMLElement reference.

applyStyle(element, {
    paddingTop: '5px'
});

Media Store

Spark provides a Store called MediaStore that models its value based on if the provided CSS media query matches.

const darkMode = new MediaStore('(prefers-color-scheme: dark)');
Clone this wiki locally