Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

@emotion/cache

Package Overview
Dependencies
5
Maintainers
4
Versions
71
Issues
File Explorer

Advanced tools

@emotion/cache

emotion's cache

    11.10.5latest

Version published
Maintainers
4
Weekly downloads
8,499,867
decreased by-14.79%

Weekly downloads

Readme

Source

@emotion/cache

createCache

createCache allows for low level customization of how styles get inserted by emotion. It's intended to be used with the <CacheProvider/> component to override the default cache, which is created with sensible defaults for most applications.

import createCache from '@emotion/cache' export const myCache = createCache({ key: 'my-prefix-key', stylisPlugins: [ /* your plugins here */ ] })

Primary use cases

  • Using emotion in embedded contexts such as an <iframe/>

  • Setting a nonce on any <style/> tag emotion creates for security purposes

  • Using emotion with a developer defined <style/> tag

  • Using emotion with custom Stylis plugins

Options

nonce

string

A nonce that will be set on each style tag that emotion inserts for Content Security Policies.

stylisPlugins

Array<Function>

A Stylis plugins that will be run by Stylis during preprocessing. Read the Stylis docs to find out more. This can be used for many purposes such as RTL.

Note:

Prefixer is just a plugin which happens to be put in default stylisPlugins. If you plan to use custom stylisPlugins and you want to have your styles prefixed automatically you must include prefixer in your custom stylisPlugins. You can import prefixer from the stylis module to do that (import { prefixer } from 'stylis');

key

string (Pattern: [^a-z-])

The prefix before class names. It will also be set as the value of the data-emotion attribute on the style tags that emotion inserts and it's used in the attribute name that marks style elements in renderStylesToString and renderStylesToNodeStream. This is required if using multiple emotion caches in the same app.

container

Node

A DOM node that emotion will insert all of its style tags into. This is useful for inserting styles into iframes or windows.

prepend

boolean

A boolean representing whether to prepend rather than append style tags into the specified container DOM node.

FAQs

What is @emotion/cache?

emotion's cache

Is @emotion/cache popular?

The npm package @emotion/cache receives a total of 6,850,669 weekly downloads. As such, @emotion/cache popularity was classified as popular.

Is @emotion/cache well maintained?

We found that @emotion/cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 4 open source maintainers collaborating on the project.

Last updated on 27 Oct 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc