NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm, #1920 most downloaded on npm
> Simple styling in React.
Latest stable
11.14.0
Last release 2 years ago
no release in 18 months
Release timing varies
gaps range from 8 days to 7 months
Nearly every release is documented
notes for 32 of 32 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
42 releases · first in 2020
Drag across the ruler to compare, or tap a release to open it.
Updated dependencies \[`e1bf17e`]:
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Updated dependencies \[`77d930d`]:
#3270 77d930d Thanks @emmatown! - Fix inconsistent hashes using development vs production bundles/exports conditions when using @emotion/babel-plugin with sourceMap: true (the default). This is particularly visible when using Emotion with the Next.js Pages router where the development condition is used when bundling code but not when importing external code with Node.js.
Updated dependencies [77d930d]:
### Patch Changes - #3232 `0ce3ed0` Thanks @ENvironmentSet! - Distribute css prop attachment over props that are union types - Updated dependencies \[
#3232 0ce3ed0 Thanks @ENvironmentSet! - Distribute css prop attachment over props that are union types
Updated dependencies []:
Development builds (and other environment-specific builds) can be used by using proper conditions (see here). Most modern bundlers/frameworks already
#3198 d8ff8a5 Thanks @Andarist! - Migrated away from relying on process.env.NODE_ENV checks to differentiate between production and development builds.
Development builds (and other environment-specific builds) can be used by using proper conditions (see here). Most modern bundlers/frameworks already preconfigure those for the user so no action has to be taken.
Default files should continue to work in all environments.
#3198 d8ff8a5 Thanks @Andarist! - Migrated away from relying on process.env.NODE_ENV checks to differentiate between production and development builds.
Development builds (and other environment-specific builds) can be used by using proper conditions (see here). Most modern bundlers/frameworks already preconfigure those for the user so no action has to be taken.
Default files should continue to work in all environments.
#3215 a9f6912 Thanks @Andarist! - Added edge-light and workerd conditions to package.json manifest to better serve users using Vercel Edge and Cloudflare Workers.
a9f6912 Thanks @Andarist! - Added edge-light and workerd conditions to package.json manifest to better serve users using Vercel Edge and Cloudflare Workers.d8ff8a5]:
Updated dependencies \[`ea84c40`]:
ea84c40]:
#3206 d1994c4 Thanks @DiegoAndai! - Improved compatibility with the upcoming @types/react for React 19 where the global JSX namespace doesn't exist anymore
#3208 56109e7 Thanks @Andarist! - Only forward defined refs to improve compatibility with the upcoming React 19
Updated dependencies [9ca22c6, a1e881b, 16d8a8c]:
65a1eea Thanks @srmagura! - Automatic labeling at runtime is now an opt-in feature. Define globalThis.EMOTION_RUNTIME_AUTO_LABEL = true before Emotion gets initialized to enable it.#3206 d1994c4 Thanks @DiegoAndai! - Improved compatibility with the upcoming @types/react for React 19 where the global JSX namespace doesn't exist anymore
#3208 56109e7 Thanks @Andarist! - Only forward defined refs to improve compatibility with the upcoming React 19
Updated dependencies [9ca22c6, b1d16b0, 16d8a8c]:
8546dd0 Thanks @srmagura! - Source code has been migrated to TypeScript so from now on type declarations will be available in the published package.304f7e3 Thanks @G-Rath! - Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written.85772c3 Thanks @emmatown! - Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written.#2558 85772c3 Thanks @emmatown! - Fixed options parameter to createEmotion from @emotion/css/create-instance incorrectly being marked as optional when it's required.
Updated dependencies [9ca22c6, 16d8a8c, 52aadc6, 52aadc6]:
### Patch Changes - #3159 `5b82631d` Thanks @iegik! - Renamed an internal hasOwnProperty to hasOwn. This avoids problems in CommonJS environments when
Updated dependencies \[`45c440fb`]:
### Patch Changes - #3048 `9357f337` Thanks @naari3! - Added ElementType to the Emotion's JSX namespace. It's defined in the same way as the one in @t
Updated dependencies \[`336f3d50`, `eed5e6cf`]:
336f3d50 Thanks @Andarist! - Added support for cascade @layers by updating the underlying parser (stylis).336f3d50 Thanks @Andarist! - Added support for cascade @layers by updating the underlying parser (stylis).Updated dependencies \[`6bd13425`]:
Updated dependencies \[`4e172c2a`]:
Updated dependencies \[`13afe030`, `c02b1214`]:
#2905 4c0005f6 Thanks @p-m-p! - Do not warn about @emotion/react being loaded twice in Vitest as that might easily happen with mocked modules.
#2929 13afe030 Thanks @Andarist! - The support for @container queries has been added by updating the underlying parser (stylis) .
Updated dependencies [13afe030, c02b1214, d8a13bca]:
Note that we don't recommend bundling Emotion. You should have very specific reasons to do so.
#2867 89b6dbb3 Thanks @Andarist! - Externalized code referencing React.useInsertionEffect to a separate @emotion/use-insertion-effect-with-fallbacks package. This package should be used in your defined externals if you bundle Emotion for whatever reason. It references useInsertionEffect in a very specific way that allows us to use it conditionally. However, if the code consuming Emotion is bundled as a library with Emotion in it then some bundlers might change the way in which we reference useInsertionEffect and that might create problems for bundlers used to consume the said library code. By externalizing this new package you can still bundle Emotion if you want to without running into this problem as you won't "destroy" the carefully crafted reference to useInsertionEffect in the process.
Note that we don't recommend bundling Emotion. You should have very specific reasons to do so.
Updated dependencies [89b6dbb3]:
### Minor Changes - #2819 `bbad8c79` Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be im
bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.bbad8c79]:
#2819 bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.
#2819 bbad8c79 Thanks @nicksrandall! - Thanks to the added exports field, the package now includes a worker condition that can be utilized by properly configured bundlers when targeting worker-like environments. It fixes the issue with browser-specific files being prioritized by some bundlers when targeting workers.
bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.bbad8c79 Thanks @nicksrandall! - exports field has been added to the package.json manifest. It limits what files can be imported from a package but we've tried our best to allow importing all the files that were considered to be a part of the public API.Updated dependencies \[`26e4e3e8`, `5e81f213`, `3055efdd`]:
#2759 Thanks @srmagura, @Andarist! - Change the argument of the shouldForwardProp option of styled from PropertyKey to string in the TypeScript definitions.
#2333 3055efdd Thanks @Andarist! - shouldForwardProp has been changed from being a bivariant method to a contravariant function - it improves the type-safety for those that type this option.
#2333 3055efdd Thanks @antongolub! - FilteringStyledOptions and StyledOptions types no longer require a type argument for the Props generic.
Updated dependencies [26e4e3e8, 5e81f213, 3055efdd]:
Updated dependencies \[`d9357621`]:
#2700 d9357621 Thanks @arturmuller! - Fixed a false positive warning for content properties that included var().
Updated dependencies [d9357621]:
1a25293f Thanks @thompsongl! - Added includeStyles option to createSerializer to optionally disable styles printing.### Patch Changes - #2677 `ff3cb164` Thanks @Jack-Works! - Change Global component to use the StyleSheet constructor of the current cache.sheet. This
ff3cb164 Thanks @Jack-Works! - Change Global component to use the StyleSheet constructor of the current cache.sheet. This is useful when cache.sheet is not the default implementation. Thanks to that the inner sheet constructed by Global can share the behavior with its "main" sheet that is hold by the cache.### Patch Changes - #2651 `39ac5b99` Thanks @Andarist! - Fixed a transpilation issue that caused useInsertionEffect to be referenced directly in the s
Updated dependencies \[`d2531639`, `2f27156a`]:
2f27156a Thanks @Andarist! - Refactored code to use the upcoming React.useInsertionEffect when it's available (this is a new hook that is going to be introduced in React 18). This shouldn't have any effect on existing codebases and the change should be transparent.#2609 242f7d8c Thanks @Andarist! - Added @emotion/babel-plugin as a dependency - this is an actual dependency of the @emotion/react/macro entrypoint and it has to be explicitly declared to fix compatibility with strict package managers.
#2615 3d672acd Thanks @srmagura! - Fix an edge case where runtime label extraction in class components led to invalid class names in Firefox. This only affected the development build of Emotion.
Updated dependencies [2f27156a]:
Updated dependencies \[`1554a7e2`]:
#2577 04681a5f Thanks @Methuselah96! - Export Keyframes type to avoid TypeScript inserting import("@emotion/serialize").Keyframes references into declaration files emitted based on a source files exporting keyframes result. This avoids issues with strict package managers that don't allow accessing undeclared dependencies.
#2590 1554a7e2 Thanks @Andarist! - Upgraded and pinned the version of Stylis - the CSS parser that Emotion uses under the hood.
Updated dependencies [1554a7e2]:
### Patch Changes - #2534 `57be9e8c` Thanks @srmagura! - Changed the implementation of the runtime label extraction in elements using the css prop (th
57be9e8c Thanks @srmagura! - Changed the implementation of the runtime label extraction in elements using the css prop (that only happens in development) to one that should yield more consistent results across browsers. This fixes some minor issues with React reporting hydration mismatches that wouldn't happen in production.Updated dependencies \[`9861a18b`]:
eb013d25 Thanks @eps1lon! - Fixed hydration mismatches if React.useId (an upcoming API in React 18) is used within a tree below our components.#2521 516fe458 Thanks @mnajdova! - Added insertionPoint option to the createCache. It can be used to insert rules after the specified element. For example, to use it with the CacheProvider from @emotion/react you can do this:
const head = document.querySelector('head')
// <meta name="emotion-insertion-point" content="">
const emotionInsertionPoint = document.createElement('meta')
emotionInsertionPoint.setAttribute('name', 'emotion-insertion-point')
emotionInsertionPoint.setAttribute('content', '')
head.appendChild(emotionInsertionPoint)
// the emotion sheets should be inserted right after the meta tag
const cache = createCache({
key: 'my-app',
insertionPoint: emotionInsertionPoint
})
function App() {
return (
<CacheProvider value={cache}>
<Main />
</CacheProvider>
)
}
9e82a991]:
Updated dependencies \[`e5beae8e`, `9ae4a91a`, `f2eda829`]:
#2498 e5beae8e Thanks @Andarist! - Fixed an edge case issue with incorrect rules being generated. When a context selector (&) was used not at the beginning of a selector (which is not valid SCSS but is allowed by the Stylis parser that we are using) within a group of selectors containing a pseudoclass then it was not replaced correctly with the current context selector.
#2500 eda5e687 Thanks @Jarred-Sumner! - Fix error loading @emotion/react in alternative JS environments
Updated dependencies [e5beae8e, 9ae4a91a, f2eda829]:
#2498 e5beae8e Thanks @Andarist! - Fixed an edge case issue with incorrect rules being generated. When a context selector (&) was used not at the beginning of a selector (which is not valid SCSS but is allowed by the Stylis parser that we are using) within a group of selectors containing a pseudoclass then it was not replaced correctly with the current context selector.
#2493 9ae4a91a Thanks @Andarist! - Improved the declared types related to Stylis. This should improve the compatibility with the types published in @types/stylis.
Updated dependencies [f2eda829]:
Updated dependencies \[`405af5ca`]:
#2441 24557d9d Thanks @garronej! - Exposed __unsafe_useEmotionCache which can be used to access the current Emotion's cache in an easier way than before. Using this might break 0-config SSR and is not recommended to be used unless there you know what you are doing and you are OK with the mentioned downside.
#2424 cd25b62d Thanks @tills13! - Use theme context when rendering components at all times. This removes a conditional usage of a React hook that could break Rules of Hooks in some scenarios.
#2428 a69929d6 Thanks @eps1lon! - Added display names to public React contexts in development builds. This helps to recognize them in React Developer Tools.
Updated dependencies [405af5ca]:
### Patch Changes - #2361 `38f9d44f` Thanks @danieldelcore, @mitchellhamilton! - Fixed moving of client-side inserted style tags from Emotion 10 when
38f9d44f Thanks @danieldelcore, @mitchellhamilton! - Fixed moving of client-side inserted style tags from Emotion 10 when intending to hydrate Emotion 11 styles resulting in losing styles in production`d0293508` #2240 Thanks @wolszczak96! - as prop has been removed from TypeScript declarations for composite components. This prop has not actually bee
d0293508 #2240 Thanks @wolszczak96! - as prop has been removed from TypeScript declarations for composite components. This prop has not actually been handled by default by styled for those components - to make styled handle it you need to provide a custom shouldForwardProp that doesn't forward the as prop.
Updated dependencies [f3c2e81d]:
4d2e732e #2206 Thanks @jimmydief! - Added export for SerializedStyles Flow type.`71ca9be3` #2181 Thanks @101arrowz! - Fixed some typing issues with React components with custom generic render functions.
71ca9be3 #2181 Thanks @101arrowz! - Fixed some typing issues with React components with custom generic render functions.`704b0092` #2180 Thanks @Andarist! - Fixed an issue with global styles containing pseudo selectors in at-rules not being able to be inserted.
`de378ab8` #2147 Thanks @macalinao! - Fixed an issue with template strings minifier crashing on two consecutive interpolations without any meaningful
de378ab8 #2147 Thanks @macalinao! - Fixed an issue with template strings minifier crashing on two consecutive interpolations without any meaningful string in between them.
Updated dependencies [ee6a673f]:
3f8bf70e #2132 Thanks @dcastil! - displayNames have been added to Global and ClassNames components so React Developer Tools should display those better now.
1ee34005 #2122 Thanks @dcastil! - Improved label extraction from the stack traces to handle components with numbers in their names.
e5843530 #2140 Thanks @hasparus! - Fixed an issue with css prop type not being added to all components that accept a string className correctly.
Updated dependencies [5469d003]:
`fdd46bdf` #2112 Thanks @Andarist! - Fixed the latest tree-shakeability improvements by adding "sideEffects": false to all internal package.json files
fdd46bdf #2112 Thanks @Andarist! - Fixed the latest tree-shakeability improvements by adding "sideEffects": false to all internal package.json files as well. This fixes hoist-non-react-statics not being dropped correctly despite of the latest improvements.`0e465d1c` #2101 Thanks @Andarist! - Improved tree-shakeability of the package. The main benefit is that bundlers should be able now to drop `hoist-no
0e465d1c #2101 Thanks @Andarist! - Improved tree-shakeability of the package. The main benefit is that bundlers should be able now to drop hoist-non-react-statics if you don't actually use our withTheme export.c470c855 #2109 Thanks @Andarist! - createEnzymeSerializer export has been removed from the root entrypoint and moved to a dedicated @emotion/jest/enzyme entrypoint. This is unfortunate because it could be considered a breaking change but it has been decided to treat this as a bug fix. It was never the intention to export this from the root entrypoint - enzyme-to-json has been marked as an optional peer dependency of @emotion/jest since the release and it was the package structure that did not match this expectation by mistake.It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:
f9feab1a #1575 Thanks @mitchellhamilton! - Removed support for @emotion/styled-base package. It has been moved to @emotion/styled and is available as @emotion/styled/base. This simplifies how the regular and base versions relate to each other and eliminates problems with stricter package managers when @emotion/styled-base was not installed explicitly by a user.
79036056 #967 Thanks @mitchellhamilton! - Remove support for deprecated innerRef prop
a72e6dc #1501 Thanks @JakeGinnivan! - TypeScript types have been significantly restructured. These changes:
css function has been restricted to prevent passing invalid typesstyled's generic parameter has been changed, if you were specifying the ComponentType you will need to remove that generic parameterstyled no longer takes a second ExtraProps parameter - instead of that move it to after the styled call. So instead of writing styled<typeof MyComponent, ExtraProps>(MyComponent)({}) you should now be writing styled(MyComponent)<ExtraProps>({})If you encounter build issues after upgrade, try removing any manually specified generic types and let them be inferred.
c6431074 #1609 Thanks @tomsseisums! - It's now easier to provide a type for Theme. Instead of creating custom instances (like before) you can augment the builtin Theme interface like this:
import '@emotion/react'
declare module '@emotion/react' {
export interface Theme {
primaryColor: string
secondaryColor: string
}
}
105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.
79036056 #967 Thanks @mitchellhamilton! - Use hooks internally for improved bundle size and a better tree in React DevTools
9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:
prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.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 rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.cf56694 #2088 Thanks @Andarist! - UMD filenames have been changed.
4d3b60d0 #1874 Thanks @connor-baer! - Added basic TS type support for as prop on styled components. It's possible to pass any component to it but it has no effect on other accepted props. This means that it's not 100% type-safe so use it sparingly and with care.
ad77ed24 #1624 Thanks @JakeGinnivan! - Added CreateStyled overload to handle when shouldForwardProp is a custom type guard for intrinsic props.
As an example, if you want to override the type of the color prop:
export const Box = styled('div', {
shouldForwardProp: (
propName
): propName is Exclude<keyof JSX.IntrinsicElements['div'], 'color'> =>
propName !== 'color'
})<{ color: Array<string> }>(props => ({
color: props.color[0]
}))
;<Box color={['green']} />
18c0d5f4 #1668 Thanks @animecyc! - Custom shouldForwardProp is being preserved now when using .withComponent. Also, when passing an additional shouldForwardProp in .withComponent's options (like this: SomeComponent.withComponent('span', { shouldForwardProp })) it's being composed with the potentially existing shouldForwardProp.
5d692a6a #1956 Thanks @eps1lon! - Upgraded csstype dependency to its v3. This is what we use to provide TypeScript typings for object styles. The upgrade should not affect any consuming code but it's worth mentioning if any edge case scenarios arise.
22935470 #1588 Thanks @FezVrasta! - StyledComponent Flow type is now polymorphic, that means you can now define the component prop types to get better type safety.
58dc08a6 #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.
Updated dependencies [c672175b, 923ded01, e3d7db87, 8a896a31, c5b12d90, 5e803106, b8476e08, debaad9a, 0a4a22ff, 5c55fd17, b0ad4f0c, 9e998e37, c65c5d88, 5c7ec859, a085003d, c7850e61, b7d21373, 5d692a6a, c5b12d90, c6431074, 828111cd, 9e998e37, 69446cb5]:
b8476e08 #1675 Thanks @mitchellhamilton! - Rename emotion-server to @emotion/server. Please change any imports of emotion-server to import @emotion/server or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
b8476e08 #1675 Thanks @mitchellhamilton! - Move create-emotion-server to @emotion/server/create-instance. Please change any imports of create-emotion-server to import @emotion/server/create-instance or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.
b8476e08 #1675 Thanks @mitchellhamilton! - Rename @emotion/core to @emotion/react. Please change any imports of @emotion/core to import @emotion/react or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
cbb8b796 #1628 Thanks @Andarist! - emotion-theming has been removed and all its exports were moved to @emotion/react package. Please import them like this import { useTheme, ThemeProvider, withTheme } from '@emotion/react' from now on.
a72e6dc #1501 Thanks @JakeGinnivan! - TypeScript types have been significantly restructured. These changes:
css function has been restricted to prevent passing invalid typesstyled's generic parameter has been changed, if you were specifying the ComponentType you will need to remove that generic parameterstyled no longer takes a second ExtraProps parameter - instead of that move it to after the styled call. So instead of writing styled<typeof MyComponent, ExtraProps>(MyComponent)({}) you should now be writing styled(MyComponent)<ExtraProps>({})If you encounter build issues after upgrade, try removing any manually specified generic types and let them be inferred.
c6431074 #1609 Thanks @tomsseisums! - It's now easier to provide a type for Theme. Instead of creating custom instances (like before) you can augment the builtin Theme interface like this:
import '@emotion/react'
declare module '@emotion/react' {
export interface Theme {
primaryColor: string
secondaryColor: string
}
}
f57a7229 #1941 Thanks @Andarist! - The way in which we provide TypeScript support for the css prop has changed. Based on the usage of our JSX factories, we can add support for css prop only for components that support className prop (as our JSX factory functions take the provided css prop, resolve it and pass the generated className to the rendered component).
For the classic runtime this has been implemented using technique described here. What is important - we no longer extend any global interfaces, so people shouldn't bump anymore into type conflicts for the css prop when using different libraries with css prop support, such as styled-components.
For the automatic runtime this has been implemented by exporting JSX namespace from the appropriate entries but this is only supported in TypeScript 4.1 or higher.
However, if you are stuck with older version of TypeScript or using the classic runtime implicitly by using our @emotion/babel-preset-css-prop then it's not possible to leverage leverage css prop support being added conditionally based on a type of rendered component. For those cases we have added a special file that can be imported once to add support for the css prop globally, for all components. Use it like this:
/// <reference types="@emotion/react/types/css-prop" />
In this particular case we are forced to extend the existing React.Attributes interface. Previously we've been extending both React.DOMAttributes<T> and JSX.IntrinsicAttributes. This change is really minor and shouldn't affect any consuming code.
843bfb11 #1630 Thanks @Andarist! - Removed default export from @emotion/css - it's main purpose was to allow css to be a Babel macro, but since babel-plugin-macros allows us to keep imports nowadays this is no longer needed. @emotion/react/macro has been added to account for this use case and appropriate changes has been made to @emotion/babel-plugin to facilitate those changes.
If you have used @emotion/css directly (it was always reexported from @emotion/react) or you have been using its macro then you should update your code like this:
-import css from '@emotion/css'
+import { css } from '@emotion/react'
// or
-import css from '@emotion/css/macro'
+import { css } from '@emotion/react/macro'
You can also use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin to do this for you.
79036056 #967 Thanks @mitchellhamilton! - Use hooks internally for improved bundle size and a better tree in React DevTools
9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:
prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.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 rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.
cf56694 #2088 Thanks @Andarist! - UMD filenames have been changed.
c672175b #1130 Thanks @jtmthf! - Support functions in arrays passed to css prop and Global's styles prop. This allows for composition of theme-accepting functions.
828111cd #1639 Thanks @Andarist! - Global imported from macro entry (@emotion/react/macro) gets source maps generated now when inline css-less expression is used as value of the styles prop.
5d692a6a #1956 Thanks @eps1lon! - Upgraded csstype dependency to its v3. This is what we use to provide TypeScript typings for object styles. The upgrade should not affect any consuming code but it's worth mentioning if any edge case scenarios arise.
7dea6d7a #1734 Thanks @Andarist! - Fixed styles inserted by <Global/> component not inheriting speedy option from a cache passed to a wrapping <CacheProvider/>.
5c55fd17 #1653 Thanks @Andarist! - Fix to what location generated source maps are pointing in case of composed styles.
75e2f9e1 #1810 Thanks @Andarist! - Add a dev-only warning about styles created with css from @emotion/react being passed to cx from <ClassNames/>.
d62d9101 #1677 Thanks @ajs139! - Warn if @emotion/react is initialized more than once in the same development environment.
a085003d #1613 Thanks @Andarist! - Add missing #__PURE__ annotations
58dc08a6 #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.
Updated dependencies [a8eb4e75, e3d7db87, 8a896a31, 42df3f3b, 4a891bf6, 1e4a741d, debaad9a, 5c55fd17, a085003d, dfe79aca, 105de5c8, 39be057b, 105de5c8, 5d692a6a, 9e998e37, c6431074, 9e998e37, 9e998e37]:
95ea2839 #2014 Thanks @Andarist! - Functions are no longer accepted as values for the style prop. This unifies the behavior with the web version of Emotion as style's equivalent is className prop and functions are not resolved for it.
139ea336 #2060 Thanks @efoken! - StyleSheet.create is used now under the hood. This means that when used in combination with React Native Web atomic class names are applied on components instead of inline styles.
79036056 #967 Thanks @mitchellhamilton! - Use hooks internally for improved bundle size and a better tree in React DevTools
95ea2839 #2014 Thanks @Andarist! - Updated css-to-react-native dependency to the 3.x version - it comes with some breaking changes listed here.
843bfb11 #1630 Thanks @Andarist! - @emotion/native & @emotion/primitives packages come with macros now. Both can be used as @emotion/native/macro & @emotion/primitives/macro respectively.
2d597857 #2058 Thanks @efoken! - Added support for the as prop.
f1b7c9d6 #1642 Thanks @Andarist! - Added basic support for accepting custom shouldForwardProp option.
db16ac35 #2013 Thanks @Andarist! - Fixed an issue with styles being lost for nested factory calls like:
const bgColor = color => css`
background-color: ${color};
`
const Text = styled.Text`
color: hotpink;
${({ backgroundColor }) => bgColor(backgroundColor)};
`
Updated dependencies [c672175b, 923ded01, c5b12d90, 5e803106, 95ea2839, b8476e08, 0a4a22ff, b0ad4f0c, 9e998e37, c65c5d88, 5c7ec859, db16ac35, a085003d, c7850e61, 95ea2839, b7d21373, 139ea336, c5b12d90, 79036056, 2d597857, 828111cd, 69446cb5]:
95ea2839 #2014 Thanks @Andarist! - Functions are no longer accepted as values for the style prop. This unifies the behavior with the web version of Emotion as style's equivalent is className prop and functions are not resolved for it.
139ea336 #2060 Thanks @efoken! - StyleSheet.create is used now under the hood. This means that when used in combination with React Native Web atomic class names are applied on components instead of inline styles.
79036056 #967 Thanks @mitchellhamilton! - Use hooks internally for improved bundle size and a better tree in React DevTools
95ea2839 #2014 Thanks @Andarist! - Updated css-to-react-native dependency to the 3.x version - it comes with some breaking changes listed here.
843bfb11 #1630 Thanks @Andarist! - @emotion/native & @emotion/primitives packages come with macros now. Both can be used as @emotion/native/macro & @emotion/primitives/macro respectively.
456be9a6 #1634 Thanks @patsissons! - Added TypeScript type definitions.
2d597857 #2058 Thanks @efoken! - Added support for the as prop.
f1b7c9d6 #1642 Thanks @Andarist! - Added basic support for accepting custom shouldForwardProp option.
11fc27f8 #1750 Thanks @Zn4rK! - Match supported components to what is exported from the latest version of React Native (0.61.5).
db16ac35 #2013 Thanks @Andarist! - Fixed an issue with styles being lost for nested factory calls like:
const bgColor = color => css`
background-color: ${color};
`
const Text = styled.Text`
color: hotpink;
${({ backgroundColor }) => bgColor(backgroundColor)};
`
Updated dependencies [95ea2839, db16ac35, 95ea2839, 139ea336, 79036056, 2d597857]:
b8476e08 #1675 Thanks @mitchellhamilton! - Rename jest-emotion to @emotion/jest. Please replace "snapshotSerializers": ["jest-emotion"] with "snapshotSerializers": ["@emotion/jest/serializer"] if you're using the snapshot serializer. Also replace any imports of jest-emotion with @emotion/jest or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
ca599c5f #1901 Thanks @Andarist! - test & print are no longer exported as named exports. If you want to access the default serializer just access the default export. This means that @emotion/jest(previously jest-emotion) can't be used directly in the snapshotSerializers option, you should use @emotion/jest/serializer instead for this.
ca599c5f #1901 Thanks @Andarist! - Refactored to use new serializers API which has been introduced in Jest 21.
cd77efbf #1920 Thanks @Andarist! - The root entry (@emotion/jest) no longer has default and serializer exports. You can still import createSerializer from it to create your own serializer if needed.
cd77efbf #1920 Thanks @Andarist! - @emotion/jest/serializer's main purpose is compatibility with Jest's snapshotSerializers option, so it no longer has a default export - it only has test & serialize exports. You can import createSerializer from the root entry (@emotion/jest) and create your own serializer if needed.
702f3fd2 #1620 Thanks @spudly! - Added the T parameter to the Matchers interface in the TypeScript definitions to make this module compatible with @types/jest@^24.0.20.
b8476e08 #1675 Thanks @mitchellhamilton! - Improve support for Enzyme's shallow rendering with the addition of the @emotion/jest/enzyme-serializer snapshot serializer.
ca599c5f #1901 Thanks @Andarist! - Improved printing of nested at-rules.
ca599c5f #1901 Thanks @Andarist! - Fixed an issue with all styles being recognized as changed in Jest 25 on unrelated changes.
e67a5be9 #1604 Thanks @Andarist! - Take specificity into account when matching styles
8a88e771 #1880 Thanks @Jimmydalecleveland! - Improved stability of the generated snapshots - styles are extracted now based on the order in which the associated with them class names appear in the serialized elements rather than based on the order of the actual rules in the document.
e67a5be9 #1604 Thanks @Andarist! - Match rules in declarations with component used as a selector
ae8c1d9d #1902 Thanks @Andarist! - Added support for handling regular React elements (objects returned from React.createElement) in the serializer and toHaveStyleRule matcher. It's possible to get those elements when traversing Enzyme's trees.
3abcf673 #2043 Thanks @Andarist! - @types/jest has been moved from the dependencies to the optional peer dependencies as it should not be installed automatically for users not using TypeScript.
Updated dependencies []:
b8476e08 #1675 Thanks @mitchellhamilton! - Rename eslint-plugin-emotion to @emotion/eslint-plugin. Please replace "plugins": ["emotion"] with "plugins": ["@emotion"] and emotion/ with @emotion/ in your rules config in your ESLint config.b8476e08 #1675 Thanks @mitchellhamilton! - Added @emotion/pkg-renaming rule for Emotion 11 migration.
8b59959f #1659 Thanks @Andarist! - Respect syntax-preference rule when using css prop.
58e8c110 #2034 Thanks @Andarist! - ESLint 7 has been added to the peer dependency range (ESLint 6 keeps being supported).
b8476e08 #1675 Thanks @mitchellhamilton! - Rename emotion to @emotion/css. Please change any imports of emotion to import @emotion/css or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
b8476e08 #1675 Thanks @mitchellhamilton! - Move create create-emotion to @emotion/css/create-instance. Please change any imports of create-emotion to import @emotion/css/create-instance or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.
105de5c8 #1572 Thanks @Andarist! - The key option is now required when creating a custom instance of a cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache. If multiple caches share the same key they might "fight" for each other's style elements.
5bea60b1 #1807 Thanks @Andarist! - Removed support for interpolating class names returned from css, so this will no longer be possible:
const cls1 = css`
color: blue;
`
const cls2 = css`
& .${cls1} {
color: red;
}
`
This has already been deprecated for the lifetime of v10.
843bfb11 #1630 Thanks @Andarist! - Removed default export from @emotion/css - it's main purpose was to allow css to be a Babel macro, but since babel-plugin-macros allows us to keep imports nowadays this is no longer needed. @emotion/react/macro has been added to account for this use case and appropriate changes has been made to @emotion/babel-plugin to facilitate those changes.
If you have used @emotion/css directly (it was always reexported from @emotion/react) or you have been using its macro then you should update your code like this:
-import css from '@emotion/css'
+import { css } from '@emotion/react'
// or
-import css from '@emotion/css/macro'
+import { css } from '@emotion/react/macro'
You can also use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin to do this for you.
9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:
prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.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 rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.cf56694 #2088 Thanks @Andarist! - UMD filenames have been changed.
5d692a6a #1956 Thanks @eps1lon! - Upgraded csstype dependency to its v3. This is what we use to provide TypeScript typings for object styles. The upgrade should not affect any consuming code but it's worth mentioning if any edge case scenarios arise.6d32d82b #1848 Thanks @osdiab! - Added speedy method to the TS type declaration of the sheet object available on Emotion instances. In addition to that - StyleSheet type is no longer exported from this package and instead CSSStyleSheet is available now. The StyleSheet type might still be imported from @emotion/sheet, but it has no speedy method and thus it's not the same as what is available in this package as CSSStyleSheet.
Updated dependencies [c672175b, a8eb4e75, e3d7db87, 8a896a31, 42df3f3b, c5b12d90, 4a891bf6, 5e803106, b8476e08, 1e4a741d, debaad9a, 0a4a22ff, 5c55fd17, b0ad4f0c, 9e998e37, c65c5d88, 5c7ec859, a085003d, dfe79aca, c7850e61, 105de5c8, 39be057b, b7d21373, 105de5c8, 5d692a6a, c5b12d90, 9e998e37, c6431074, 828111cd, 9e998e37, 9e998e37]:
105de5c8 #1572 Thanks @Andarist! - From now on key option is required. Please make sure it's unique (and not equal to "css") as it's used for linking styles to your cache. If multiple caches share the same key they might "fight" for each other's style elements.
9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
It has been completely rewritten and comes with some breaking changes. The most notable ones that might affect Emotion users are:
prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.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 rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.4a891bf6 #1473 Thanks @jcharry! - The new prepend option can make Emotion add style tags at the beginning of the specified DOM container instead of the end.a8eb4e75 #1998 Thanks @Andarist! - Styles are now correctly extracted from the correct cache (key-sensitive) on the server.
105de5c8 #1572 Thanks @Andarist! - Fixed issue with SSRed styles causing a React rehydration mismatch between server & client when cache was created in render.
39be057b #1997 Thanks @Andarist! - From now on an empty rule will get inserted into the DOM in non-production environments if it gets created by the user. This helps to grab used keys from the (JS)DOM even for caches that have not inserted any actual rules to the document yet. It allows @emotion/jest to find those and serialize Emotion classes properly in situations like this:
import styled from '@emotion/styled/macro'
import { render } from '@testing-library/react'
const Div = styled.div``
test('foo', () => {
const { container } = render(<Div />)
expect(container).toMatchSnapshot()
})
Updated dependencies [42df3f3b, 4a891bf6, 1e4a741d, debaad9a, dfe79aca, 9e998e37, 9e998e37]:
9e3671c4 #2076 Thanks @Andarist! - Removed runtime option that was introduced to this preset and deprecated shortly after that. If you want to configure runtime: "automatic", replace @emotion/babel-preset-css-prop with @babel/preset-react and @emotion/babel-plugin. You can find out how to configure things properly here: https://emotion.sh/docs/css-prop#babel-preset
c5b12d90 #1220 Thanks @mitchellhamilton! - Removed support for the instances option, any usage of it should be replaced with the importMap option
c7850e61 #1656 Thanks @Andarist! - autoLabel option no longer is a simple boolean. Instead we accept now 3 values: dev-only (the default), always and never.
Each possible value for this option produces different output code:
dev-only we optimize the production code, so there are no labels added there, but at the same time we keep labels for development environments,always we always add labels when possible,never we disable this entirely and no labels are added.c5b12d90 #1220 Thanks @mitchellhamilton! - Added the importMap option which allows you to tell @emotion/babel-plugin what imports it should look at to determine what it should transform so if you re-export Emotion's exports, you can still use the Babel transforms
c672175b #1130 Thanks @jtmthf! - Adjust how arrays passed to css prop are transformed so function elements can be resolved at runtime.
0a4a22ff #1651 Thanks @Andarist! - Allow labelFormat option to be a function.
b8476e08 #1675 Thanks @mitchellhamilton! - Rename babel-plugin-emotion to @emotion/babel-plugin. Please replace "plugins": ["emotion"] with "plugins": ["@emotion"] in your Babel config.
c5b12d90 #1220 Thanks @mitchellhamilton! - Removed support for the instances option, any usage of it should be replaced with the importMap option
c7850e61 #1656 Thanks @Andarist! - autoLabel option no longer is a simple boolean. Instead we accept now 3 values: dev-only (the default), always and never.
Each possible value for this option produces different output code:
dev-only we optimize the production code, so there are no labels added there, but at the same time we keep labels for development environments,always we always add labels when possible,never we disable this entirely and no labels are added.b7d21373 #2080 Thanks @Andarist! - cssPropOptimization defaults now to true regardless of the @emotion/react import presence.
c5b12d90 #1220 Thanks @mitchellhamilton! - Added the importMap option which allows you to tell @emotion/babel-plugin what imports it should look at to determine what it should transform so if you re-export Emotion's exports, you can still use the Babel transforms
c672175b #1130 Thanks @jtmthf! - Adjust how arrays passed to css prop are transformed so function elements can be resolved at runtime.
5e803106 #1893 Thanks @Andarist! - Added support for converting assignment expressions to labels in cases like this:
styles = css``
Timeline.Item = styled.li``
Timeline.Item.Anchor = styled.a``
0a4a22ff #1651 Thanks @Andarist! - Allow labelFormat option to be a function.
5c7ec859 #1805 Thanks @Andarist! - Requirements for a label extraction have been relaxed. In certain situations it was previously required for a containing function to have a PascalCased name.
828111cd #1639 Thanks @Andarist! - Global gets handled by the Babel plugin now - this gives inline css-less expressions source maps.
b0ad4f0c #1602 Thanks @Andarist! - Avoid transpiling vanilla emotion calls in already transpiled code to avoid double labels and such
9e998e37 #1817 Thanks @Andarist! - Fixed an issue in our tagged template expressions minifier which has caused whitespace before nested orphaned pseudo selectors being incorrectly removed. In a selector like & :hover the whitespace before colon has a semantic meaning and needs to be preserved.
Updated dependencies [e3d7db87, 8a896a31, 5c55fd17, a085003d, 5d692a6a, c6431074]:
`9c4ebc16` #2030 Thanks @Andarist! - Release candidate version.
9c4ebc16]:
9c4ebc16]:
9c4ebc16]:
9c4ebc16]:
### Patch Changes - Updated dependencies \[]: - @emotion/react@11.0.0-next.19
Updated dependencies \[`76e3dc4d`]:
76e3dc4d]:
76e3dc4d]:
`18c0d5f4` #1668 Thanks @animecyc! - Custom shouldForwardProp is being preserved now when using .withComponent. Also, when passing an additional shoul
18c0d5f4 #1668 Thanks @animecyc! - Custom shouldForwardProp is being preserved now when using .withComponent. Also, when passing an additional shouldForwardProp in .withComponent's options (like this: SomeComponent.withComponent('span', { shouldForwardProp })) it's being composed with the potentially existing shouldForwardProp.23faf9ef #1996 Thanks @Andarist! - Fixed an issue with wrapped class components not having a type for the ref prop.
0895f1f3 #1995 Thanks @Andarist! - Fixed an issue with typing for the as prop not being provided to components created using component factories available on the styled factory (e.g. styled.div).
Updated dependencies [debaad9a, 58b2bbca]:
58b2bbca #1981 Thanks @Andarist! - Changed the key of the global flag that helps us identify that @emotion/react has been loaded more than once to include the current major version of @emotion/react.
Updated dependencies [a8eb4e75, dfe98028, debaad9a, 39be057b, 39be057b]:
`5d692a6a` #1956 Thanks @eps1lon! - Upgraded `csstype` dependency to its v3. This is what we use to provide TypeScript typings for object styles. The
`58dc08a6` #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.
58dc08a6 #1837 Thanks @arcanis! - Fixed TS compatibility under PnP environments by making @types/react an optional peer dependency.f57a7229 #1941 Thanks @Andarist! - The way in which we provide TypeScript support for css prop has changed. Based on usage of our jsx pragma we are able to add support for css prop only for components that support className prop (as our jsx factory function takes provided css prop, resolves it and pass the generated className to the rendered component). This has been implemented using technique described here. What is important - we no longer extend any global interfaces, so people shouldn't bump anymore into type conflicts for the css prop when using different libraries with the css prop support, such as styled-components.
However, it's not possible to leverage css prop support being added conditionally based on a type of rendered component when one is not using our jsx pragma. For those cases when people use our pragma implicitly (for example when using our @emotion/babel-preset-css-prop) we have added special file that can be imported once to add support for the css prop globally, for all components. Use it like this:
import {} from '@emotion/react/types/css-prop'
In this particular case we are forced to extend the existing React.Attributes interface. Previously we've been extending both React.DOMAttributes<T> and JSX.IntrinsicAttributes. This change is really minor and shouldn't affect any consuming code.
Updated dependencies [4d3b60d0, 58dc08a6, 6d32d82b]:
It has been completely rewritten and comes with some breaking changes. Most notable ones that might affect Emotion users are:
9e998e37 #1817 Thanks @Andarist! - The parser we use (Stylis) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
It has been completely rewritten and comes with some breaking changes. Most notable ones that might affect Emotion users are:
prefix option. This was always limited to turning off all of some of the prefixes as all available prefixes were on by default. The prefix option is gone and to customize which prefixes are applied you need to fork (copy-paste) the prefixer plugin and adjust it to your needs. While this being somewhat more problematic to setup at first we believe that the vast majority of users were not customizing this anyway. By not including the possibility to customize this through an extra option the final solution is more performant because there is no extra overhead of checking if a particular property should be prefixed or not.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 rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.`105de5c8` #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.
105de5c8 #1572 Thanks @Andarist! - [data-emotion] attribute on SSRed styled has changed. You should never rely on it though.7dea6d7a #1734 Thanks @Andarist! - Fixed styles inserted by <Global/> component not inheriting speedy option from a cache passed to a wrapping <CacheProvider/>.be2eb614 #1806 Thanks @Andarist! - Do not warn about @emotion/react being loaded twice in Jest. For some reason Jest sometimes evaluates modules twice when jest.mock is being called.75e2f9e1 #1810 Thanks @Andarist! - Add a dev-only warning about styles created with css from @emotion/react being passed to cx from <ClassNames/>.
Updated dependencies [e3d7db87, 105de5c8, 105de5c8, 5bea60b1, 105de5c8, 105de5c8]:
Updated dependencies [`f08ef5a3`, `b79781f8`]:
`b8476e08` #1675 Thanks @emmatown! - Rename @emotion/core to @emotion/react. Please change any imports of @emotion/core to import @emotion/react or us
b8476e08 #1675 Thanks @emmatown! - Rename @emotion/core to @emotion/react. Please change any imports of @emotion/core to import @emotion/react or use the @emotion/pkg-renaming ESLint rule from @emotion/eslint-plugin.affed3dd #1702 Thanks @Andarist! - Fix issue with published TypeScript test files augmenting Theme interface.d62d9101 #1677 Thanks @ajs139! - Warn if @emotion/react is initialized more than once in the same development environment.1e4a741d, 2fa7a213, b8476e08, dfe79aca, b8476e08, b8476e08, b8476e08, dfe79aca]:
One column per quarter.