dynamic-stylesheet
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    dynamic-stylesheet

    npm-version 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

    Install

    npm i dynamic-stylesheet

    DownloadsWeekly Downloads

    11

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.1 kB

    Total Files

    10

    Last publish

    Collaborators

    • zhangyu1995