
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@emotion/cache
Advanced tools
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 */
]
})
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
noncestring
A nonce that will be set on each style tag that emotion inserts for Content Security Policies.
stylisPluginsArray<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 customstylisPluginsand you want to have your styles prefixed automatically you must include prefixer in your customstylisPlugins. You can importprefixerfrom thestylismodule to do that (import { prefixer } from 'stylis');
keystring (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.
containerNode
A DOM node that emotion will insert all of its style tags into. This is useful for inserting styles into iframes or windows.
prependboolean
A boolean representing whether to prepend rather than append style tags into the specified container DOM node.
Styled-components is another CSS-in-JS library that allows you to use tagged template literals to style your components. It creates scoped styles without the need for manual cache management, which differs from @emotion/cache where you can configure and manage your own cache.
JSS (JavaScript Style Sheets) is a CSS-in-JS library that allows for similar customization and optimization of style sheets. JSS provides a more extensive API for managing rules and stylesheets programmatically, which can be seen as more flexible compared to the focused cache management approach of @emotion/cache.
FAQs
emotion's cache
The npm package @emotion/cache receives a total of 13,857,268 weekly downloads. As such, @emotion/cache popularity was classified as popular.
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.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.