Socket
Book a DemoInstallSign in
Socket

extract-emotion-styles

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-emotion-styles

Extract styles from your emotion-themed components, then get them as CSS Text or re-apply them to a classname of your choosing.

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Audal Labs Logo

extract-emotion-styles

Extract styles from your emotion-themed components, then get them as CSS Text or re-apply them to a classname of your choosing.

npm i extract-emotion-styles

Why build this?

Emotion (and CSS-in-JS libraries generally) make developing great components super fast - but what happens when you need to work with libraries that bake-in classnames or are using dangerouslySetInnerHTML ingested from somewhere else? This library solves all of your styling issues in these scenarios - so you can continue to use Emotion, and style uncontrolled HTML and components just like you would any other Emotion component.

What can I do with this?

  • Get the styles from an existing Emotion-styled component as CSS text
  • Apply styles from an existing Emotion-styled component to any DOM selector of your choosing

API

Function NameDescriptionExpectsReturns
parseComponentToStyleTake a single Emotion-themed component and return a string of CSS classes.component: The component you'd like to extract styles from.

toClassName (optional): replace the component's Emotion-generated classname with a classname of your choosing in the extracted rules.

shouldUnmount (optional, default: true): control whether the generated React instance should still be available after styles are extracted. Useful for debugging.
All found CSS styles as a string.
applyComponentStylesToClassTake a single Emotion-themed component, and apply its styles directly to a different class name.component: The component you'd like to extract styles from.

toClassName: replace the component's Emotion-generated classname with a classname of your choosing in the extracted rules.

shouldUnmount (optional, default: true): control whether the generated React instance should still be available after styles are extracted. Useful for debugging.
No return
addRawCssToGlobalStylesAdd additional CSS styles globally to your document. Useful for adding additional styles/overriding Emotion styles.rawCSS: Plain CSS text as a single stringNo return

Keywords

emotion

FAQs

Package last updated on 14 Mar 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.