container-class

0.1.2 • Public • Published

container-class

Manage CSS classes on an element that reflect exclusive state based on a slug. For example, if you want to toggle visual theme changes in a page, you could do this.

var containerClass = require('container-class');
var el = document.querySelector('html');
containerClass(el, 'theme', 'dark');

The renderd DOM would be:

<html class="theme-dark">....</html>

If you wanted to update the page theme, like after some user selection, you would:

containerClass(el, 'theme', 'bold');

And the DOM would now be:

<html class="theme-bold">....</html>

Readme

Keywords

none

Package Sidebar

Install

npm i container-class

Weekly Downloads

4

Version

0.1.2

License

MIT

Last publish

Collaborators

  • sjwilliams