Dynamically load and operate css links
npm i dynamic-css-link
It's easy to load a css link.
import DynamicCssLink from 'dynamic-css-link';
const dcl = new DynamicCssLink();
const [light] = dcl.use({ src: './light.css' })
// dcl.hide(light)
// dcl.teardown(light)
This example show how to load two css link and operate them.
import DynamicCssLink from 'dynamic-css-link';
const dcl = new DynamicCssLink();
const [light, dark] = dcl.use([
{ src: './light.css' },
{ src: './dark.css', alternative: true } // Applied by default, but disabled.
]);
setTimeout(() => {
dcl.show(dark).hide(light);
}, 4000);