dynamic-stylesheet
v1.0.0
Published
dynamic inject css with javascript
Downloads
97
Readme
dynamic-stylesheet
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