dcx

1.1.0 • Public • Published

dcx

Simple class name manager for DOM elements, inspired by classnames 200 bytes gzipped.

Why would you use this? Good question. Sometimes managing DOM state outside of a framework like React get's messy. Usually a good example is managing sticky header navigation styles based on template, scroll position, etc. This makes that easier :) It's also a great compliment to frameworkless utilities like picoapp.

Install

npm i dcx --save

Usage

Bind an instance to a single DOM node:

import dcx from 'dcx'

const cx = dcx(document.getElementById('root'))

Then, dcx implements essentially the same API as classnames:

cx('foo', {
  'bar': true,
  'baz': false,
}, 'qux')

document.getElementById('root').className // foo bar qux

License

MIT License © Eric Bailey

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    1
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i dcx

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

5.49 kB

Total Files

8

Last publish

Collaborators

  • estrattonbailey
  • wagz