Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.01 KB

README.md

File metadata and controls

41 lines (27 loc) · 1.01 KB

dynamic-stylesheet

npm-version codecov bundlesize-js-image

dynamic inject css with javascript.

Install

npm install dynamic-stylesheet
yarn add dynamic-stylesheet

Usage

import { injectCSS, updateCSS } from 'dynamic-stylesheet'

const styleText = ".container:before{ content:'before content' }"

// default insert to document.head
injectCSS(styleText)
// attach to element
injectCSS(styleText, { attachTo: document.body })

// updateCSS will use the same node with the same key
updateCSS(styleText, 'mark-key')

const updateStyleText = ".container:after{ content:'after content' }"

updateCSS(updateStyleText, 'mark-key')

License

MIT