styled-components
6.6.0 · 12 Oct 2026MIT14.8M / weekRepositoryHomepagenpmAtom feed
194 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
6.6.0
12 Oct 2026Added a
StyledComponent<Target, Props>type for annotating explicitly-typed styled component exports.Packages that emit their own declaration files, including any project using
isolatedDeclarations, must annotate every exported styled component, and there was no public type for it: consumers reached into internal paths or hand-assembled one that dropped members like a wrapped component's hoisted statics.StyledComponentis exported from the web and native entries. Name the target and props as you passed them tostyled:import styled, { type StyledComponent } from 'styled-components'; export const Card: StyledComponent<'div', { $active?: boolean }> = styled.div<{ $active?: boolean; }>`...`; export const CloseButton: StyledComponent<typeof IconButton> = styled(IconButton)`...`;It resolves to the exact type
styled(Target)<Props>produces, so the annotation is not lossy.Fixed
attrsno longer applying its value when a prop was explicitly passed asundefined(the 6.3.12 to 6.5.x behavior).styled.button.attrs(({ type = 'button', ...rest }) => ({ type, ...rest }))rendered withouttype="button"when the caller passedtype={undefined}, and an object-form default such as.attrs({ type: 'button' })was lost the same way, including through a wrapper component that spreads its own props over the styled component.attrsnow always wins for the keys it returns, matching every other case where a prop is passed alongsideattrs.Also fixed: a prop passed explicitly as
undefined(and not overridden byattrs) is now forwarded to a wrapped component so that component can fall back to its own default, the pattern MUI'sButtonBaserelies on (for example<Root role="button" {...props} />). Wrapped components have dropped this prop entirely since v6.0, so a component that checks'role' in propsor merges{...defaults, ...props}to detect an explicitly-passed prop may see and behave differently now that the key is present again. This only applies when wrapping another component; a DOM tag such asstyled.divstill drops theundefinedprop entirely, since browsers have no notion of an "undefined" attribute.If you were relying on an explicit
undefinedto clear anattrsdefault, use the function form and check for the prop's presence instead:styled.a.attrs(props => ('rel' in props ? {} : { rel: 'noopener' }))``;Passing
rel={undefined}now renders norelattribute, and omitting the prop rendersrel="noopener".React Native already forwarded an explicit
undefinedprop to a wrapped component; it now also matches web in never forwarding anundefinedthatattrsitself produced.Rendering styled-components on the server with the edge runtime (for example
export const runtime = 'edge'in a Next.js route) now fails with a clear message that names the fix: use the Node.js runtime for routes that render styled-components. Previously the same setup ended in an obscure crash, either atnext buildor on the first request.
Minor Changes
Added a
StyledComponent<Target, Props>type for annotating explicitly-typed styled component exports.Packages that emit their own declaration files, including any project using
isolatedDeclarations, must annotate every exported styled component, and there was no public type for it: consumers reached into internal paths or hand-assembled one that dropped members like a wrapped component's hoisted statics.StyledComponentis exported from the web and native entries. Name the target and props as you passed them tostyled:import styled, { type StyledComponent } from 'styled-components'; export const Card: StyledComponent<'div', { $active?: boolean }> = styled.div<{ $active?: boolean; }>`...`; export const CloseButton: StyledComponent<typeof IconButton> = styled(IconButton)`...`;It resolves to the exact type
styled(Target)<Props>produces, so the annotation is not lossy.
Patch Changes
Fixed
attrsno longer applying its value when a prop was explicitly passed asundefined(the 6.3.12 to 6.5.x behavior).styled.button.attrs(({ type = 'button', ...rest }) => ({ type, ...rest }))rendered withouttype="button"when the caller passedtype={undefined}, and an object-form default such as.attrs({ type: 'button' })was lost the same way, including through a wrapper component that spreads its own props over the styled component.attrsnow always wins for the keys it returns, matching every other case where a prop is passed alongsideattrs.Also fixed: a prop passed explicitly as
undefined(and not overridden byattrs) is now forwarded to a wrapped component so that component can fall back to its own default, the pattern MUI'sButtonBaserelies on (for example<Root role="button" {...props} />). Wrapped components have dropped this prop entirely since v6.0, so a component that checks'role' in propsor merges{...defaults, ...props}to detect an explicitly-passed prop may see and behave differently now that the key is present again. This only applies when wrapping another component; a DOM tag such asstyled.divstill drops theundefinedprop entirely, since browsers have no notion of an "undefined" attribute.If you were relying on an explicit
undefinedto clear anattrsdefault, use the function form and check for the prop's presence instead:styled.a.attrs(props => ('rel' in props ? {} : { rel: 'noopener' }))``;Passing
rel={undefined}now renders norelattribute, and omitting the prop rendersrel="noopener".React Native already forwarded an explicit
undefinedprop to a wrapped component; it now also matches web in never forwarding anundefinedthatattrsitself produced.Rendering styled-components on the server with the edge runtime (for example
export const runtime = 'edge'in a Next.js route) now fails with a clear message that names the fix: use the Node.js runtime for routes that render styled-components. Previously the same setup ended in an obscure crash, either atnext buildor on the first request.Type-checking is faster when you annotate exported styled components with an explicit type, the pattern that packages emitting their own declaration files (including any project using
isolatedDeclarations) rely on. The improvement is largest in codebases that annotate many components built on intrinsic tags such asstyled.div,styled.span, andstyled.button, and wrappers over polymorphic components whose props are a union.Nothing about the styled component's type changes for your code: props,
defaultProps,propTypes, ref forwarding, andaspolymorphism all behave exactly as before. This is purely a type-check speedup.Fixed a typo in the
useThemeerror message's example code (a misspelled component name in error 18), so the copy-pasted example compiles as written.Fixed global styles from
createGlobalStyledisappearing in React Server Components: a global style rendered in a loading state (a React<Suspense>fallback) and again once the real content streamed in could vanish entirely once the fallback was replaced. The same loss could happen across a client-side navigation when a global style was rendered by both a layout and one of its pages, and the layout's copy never re-rendered.Each server-rendered instance of a global style now carries its own styles, so a global style shown in more than one place in a request always survives, whether the page reveals streamed content or the user navigates to a sibling route.
Fixed a crash ("Rendered fewer hooks than expected") and a related stale-style bug for components that call a React hook, or read any value outside their props and theme, from inside a style interpolation. This affected
@mui/styled-engine-scwith MUI X DataGrid, which calls hooks within an interpolation, and was a regression introduced in 6.4.0.Style interpolations now run on every render, so a hook called inside one runs consistently and a value read inside one always reflects its current state.
If a component re-renders often with unchanged props and its interpolations are expensive, wrap it in
React.memoto skip those re-renders. That is the right place to bail out, because only the calling code knows the full set of inputs its styles depend on.Fixed
//JavaScript-style line comments in React Native style declarations. Only/* */block comments were recognized before; a//comment left in a template literal was parsed as part of the surrounding CSS, which could drop or corrupt the styles that followed it on the same line. Line comments are now stripped the same way block comments already were, while a URL used as a raw value (for exampleurl(http://example.com/image.png)or an unquotedhttps://value in a custom property) is left untouched.Fixed styles disappearing from a server-rendered component when it is revealed from behind a React
<Suspense>boundary, such as a streaming Next.js route (includingcacheComponents). A component shown first in a Suspense fallback and then in the resolved content kept its class name but lost its CSS, because the rule had been emitted only inside the fallback that React discards on reveal.Each server-rendered instance now carries its own inline
<style>, so its styles always travel with it and survive the boundary. The data React sends for server components includes each distinct style once on React 19, however many instances repeat it. In the HTML, nearby duplicates compress away almost for free under gzip, but gzip can only look back about 32 KB, so once repeats are farther apart on the page each one costs roughly its own compressed size; brotli's much larger window keeps it cheap regardless of distance. Only a very large repeated list (thousands of instances of one component on a single page) is worth restyling from a single parent element, and a development-only warning points that out if it happens.styled-components now installs the stylis type declarations its own published types rely on.
The shipped declarations reference types from
stylis(thestylisPluginsoption andstylisPluginRSC), andstylisships no types of its own. WithskipLibCheckturned off, a project that had not installed@types/stylisitself could fail to type-check with an error inside styled-components' declarations. Nothing changes at runtime.Fixed the shipped types failing to compile, with
skipLibCheckturned off, against@types/react16, 17, and 18.2.6 through 18.2.11. Those versions don't declare the<search>HTML element, and styled-components' types assumed they did. The published types now compile on every supported@types/react.styled.searchis present in the types on every version, and accepts the same props it did before, so no existing code stops compiling.Fixed an error inside styled-components' own type declarations, with
skipLibCheckturned off, for projects using React 16 or 17 type packages or without@types/react-dominstalled. TheServerStyleSheetstreaming API's types referenced a type that only@types/react-dom18 and later provide.interleaveWithNodeStreamstill accepts the result ofrenderToPipeableStreamand Node readable streams exactly as before.Added a development-only warning for when the server and the browser are running different versions of styled-components. Class names are derived in part from the library's own version, so a mismatch made every server-rendered class name silently fail to match on the client, with no hint as to why styles disappeared or hydration broke. The warning names both versions and points at
npm ls styled-componentsto find the duplicate. A page that intentionally hosts more than one app, each on its own styled-components version (for example a micro-frontend setup), can ignore it. It is stripped from production builds.
6.5.3
15 Aug 2026Fix TypeScript errors in projects that augment React HTML props with a
data-*template-literal index signature.
6.5.2
11 Aug 2026.attrs()is cheaper to type-check.Two costs on the
.attrspath are gone. Object-form.attrs()left the rendered target unchanged but still re-resolved that target's whole prop bag on every call, making.attrson an HTML or SVG tag far costlier than on a wrapped component; it now reuses the props already resolved for the tag. Separately, making attrs-provided keys optional ran an avoidably expensive pass over the target's full prop set on every attrs component. Together these cut consumer type-check work measurably across every.attrsform, with no change to the resulting component's accepted props. Redirecting the target with.attrs({ as }), including the function form, is unaffected.Explicitly annotated styled components type-check faster.
Assigning a styled component to an explicit type, as
isolatedDeclarationsand any package that emits.d.tsfiles must (const Button: IStyledComponentBase<'web', ...> = styled.button``), used to be several times more expensive to check than an inferred one, because the annotation'sstyleand the component's widenedstyle` were two different csstype representations that the checker compared property by property.The inline
stylewidening now builds on React's ownCSSProperties, the same type a hand-written annotation carries, so that comparison short-circuits. On a 40-component fixture this cut the types created for the annotated pattern by about 21%, with no change to whatstyleaccepts: CSS custom properties, a component's own narrowstyle, andstyle={undefined}all behave exactly as before.styled()wrapping a generic polymorphic component keeps its declared props narrow.Wrapping a component whose props are generic over an element type, such as the common
<C extends React.ElementType>(props: PolymorphicProps<C, OwnProps>)pattern, used to let the styled result accept prop values the component itself rejects:styled(Button)would takevariant="anything"even though<Button variant="anything">is a type error. The wrapper now narrows those props exactly as the direct component does, so a bad value is caught in both places. Valid props, children, and plain (non-generic) targets are unaffected.
6.5.1
7 Aug 2026Fix a styled component silently dropping props declared as a union whose members have no prop in common, which left every one of those props rejected. The same applied when
aspointed at a component with such props. Where every member's props are optional the union is still flattened, so declare the combined optional shape instead.Styled components now report the same debug value to React DevTools on every render. Previously the value was only reported on renders that recomputed styles, so it disappeared from the DevTools panel whenever a component re-rendered with unchanged style props.
Fix wrapping a component whose props are a union. Since 6.5.0 the wrapped version accepted only the props common to every member of the union, so a prop belonging to just one member was rejected even though the unwrapped component accepted it.
6.5.0
4 Aug 2026React Native components now check
styleagainst React Native's own style types. Web-only CSS such asfloat, and CSS custom properties such as--brand, were previously accepted even though React Native has never done anything with them at runtime. They now surface as a type error where you write them instead of silently doing nothing.const Card = styled.View``; <Card style={{ padding: 16 }} />; // unchanged <Card style={{ float: 'left' }} />; // now a type errorWeb components are unaffected and still accept custom properties.
Declaring your own
styleprop type now constrains the fields you name while leaving the rest of CSS alone. Previously a declaration likestyled.div<{ style?: { width: number } }>was quietly ignored, because the built-in style type was applied after your props, so any CSS value was still accepted. Nowwidthhas to be a number, whilecolor, custom properties, and everything else you did not mention keep working as before.To remove a field rather than constrain it, declare it as
never. To make your type the only thing accepted, wrap it in the newCustomStylehelper, which removes every field you did not list:const Box = styled.div<{ style?: CustomStyle<{ width: number }> }>``;The constraint holds when the component is rendered through
asorforwardedAs, so it cannot be sidestepped by rendering the same component as a different tag. Note thatCustomStyleremoves CSS custom properties too, since they are among the fields you did not list.One thing to know if you use
exactOptionalPropertyTypes: on a component that declares its ownstyle, passingstyle={undefined}explicitly is now rejected. Leaving the prop off is unaffected. Writestyle?: { width: number } | undefinedin your declaration if you need to pass it explicitly.Relatedly, reading the style type back off a component (for example with
React.ComponentProps) now reports that CSS custom properties are accepted, which matches what was already allowed when rendering.Large TypeScript projects type-check dramatically faster. On a 500-component app,
tsccheck time drops to under a quarter of what 6.4.4 takes and peak memory to under a third, which resolves the out-of-memory failures some projects hit after upgrading past 6.4.2. Both are now better than 6.4.2 was, so there is no longer a reason to pin to it. Editor responsiveness improves by the same margin, and autocomplete onastargets is unchanged.
Minor Changes
React Native components now check
styleagainst React Native's own style types. Web-only CSS such asfloat, and CSS custom properties such as--brand, were previously accepted even though React Native has never done anything with them at runtime. They now surface as a type error where you write them instead of silently doing nothing.const Card = styled.View``; <Card style={{ padding: 16 }} />; // unchanged <Card style={{ float: 'left' }} />; // now a type errorWeb components are unaffected and still accept custom properties.
Declaring your own
styleprop type now constrains the fields you name while leaving the rest of CSS alone. Previously a declaration likestyled.div<{ style?: { width: number } }>was quietly ignored, because the built-in style type was applied after your props, so any CSS value was still accepted. Nowwidthhas to be a number, whilecolor, custom properties, and everything else you did not mention keep working as before.To remove a field rather than constrain it, declare it as
never. To make your type the only thing accepted, wrap it in the newCustomStylehelper, which removes every field you did not list:const Box = styled.div<{ style?: CustomStyle<{ width: number }> }>``;The constraint holds when the component is rendered through
asorforwardedAs, so it cannot be sidestepped by rendering the same component as a different tag. Note thatCustomStyleremoves CSS custom properties too, since they are among the fields you did not list.One thing to know if you use
exactOptionalPropertyTypes: on a component that declares its ownstyle, passingstyle={undefined}explicitly is now rejected. Leaving the prop off is unaffected. Writestyle?: { width: number } | undefinedin your declaration if you need to pass it explicitly.Relatedly, reading the style type back off a component (for example with
React.ComponentProps) now reports that CSS custom properties are accepted, which matches what was already allowed when rendering.Large TypeScript projects type-check dramatically faster. On a 500-component app,
tsccheck time drops to under a quarter of what 6.4.4 takes and peak memory to under a third, which resolves the out-of-memory failures some projects hit after upgrading past 6.4.2. Both are now better than 6.4.2 was, so there is no longer a reason to pin to it. Editor responsiveness improves by the same margin, and autocomplete onastargets is unchanged.
Patch Changes
Fixed
refbeing rejected on React Native components created with the shorthand syntax, such asstyled.TextInput. Passing a ref, or a ref callback whose parameter you have not annotated, now works the same way it does withstyled(TextInput).Also fixed a type error when a component's
attrscallback is given an explicit parameter type, as instyled.div.attrs<MyProps>(props => props).Fixed components built on targets whose props cannot be inspected, such as Mantine's polymorphic components, rejecting
childrenand the target's own props once you added a prop of your own:const Styled = styled(MantineButton)<{ $variant: 'a' | 'b' }>``; <Styled $variant="a" variant="filled"> this now works </Styled>;Wrapping such a target without adding props already worked; adding one turned the permissiveness off. Your own declared props stay strictly typed either way.
6.4.4
18 Jul 2026Reduce TypeScript type-checking cost for styled components, most noticeably
styled(Component)wrappers and polymorphicasusage. Large codebases that saw elevatedtscmemory and type-instantiation counts get lower type-check memory and time, with no change to the emitted types or runtime behavior.
6.4.3
24 Jun 2026Fix a TypeScript error when wrapping a component whose props can't be statically read, such as Mantine v7's polymorphic-factory components (
Button,Card,Menu.Item, and similar). These styled components no longer reject every prop, includingchildren; arbitrary props are accepted again at the JSX call site and via.attrs(), while components with readable prop types stay fully type-checked.Keep TypeScript attribute autocomplete working while you type props on a polymorphic styled component. When a component renders a different element through
as(for exampleas="video"), beginning to type a new prop name could make the whole suggestion list vanish; the rendered element's props now keep autocompleting as you go.
6.4.2
19 May 2026Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
Apply all chain levels' styles when an extended styled component renders with the
asprop under Preact'sreact-compat.Respect a custom
toStringon plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.
Patch Changes
Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
Apply all chain levels' styles when an extended styled component renders with the
asprop under Preact'sreact-compat.Respect a custom
toStringon plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.Fix a TypeScript error when wrapping a component whose props include an
asprop with a non-string type (such as Next.jsLink'sas?: Url). The styled component now accepts either the styled-components polymorphism value or the wrapped component's ownastype, so spreading the wrapped component's props onto the styled component is assignable again.Restore reliable styling in production browser bundles built without a runtime
processglobal.
6.4.1
21 Apr 2026Fix a performance regression in 6.4.0 where dynamic
createGlobalStylecomponents caused significant re-render slowdowns. Also restores pre-6.4 cascade ordering when multiple instances of the samecreateGlobalStylecoexist.Fix outdated dev-mode error messages for keyframes-in-untagged-strings and component-selector references that still pointed at
www.styled-components.comand described behavior from styled-components v3.
6.4.0
9 Apr 2026- Removed
Dropped IE11 support: ES2015 build target, inlined unitless CSS properties (removing @emotion/unitless dependency), removed legacy React class statics from hoist and other unnecessary code.
.attrs()improvements: props supplied via attrs are now automatically made optional on the resulting component (previously required even when attrs provided a default). Also fixes a bug where the attrs callback received a mutable props object that could be changed by subsequent attrs processing; it now receives an immutable snapshot.Add
createTheme(defaultTheme, options?)for CSS variable theming that works across RSC and client components.Returns an object with the same shape where every leaf is
var(--prefix-path, fallback). Pass it toThemeProviderfor stable class name hashes across themes (no hydration mismatch on light/dark switch).const theme = createTheme({ colors: { primary: '#0070f3' } }); // theme.colors.primary → "var(--sc-colors-primary, #0070f3)" // theme.raw → original object // theme.vars.colors.primary → "--sc-colors-primary" // theme.resolve(el?) → computed values from DOM (client-only) // theme.GlobalStyle → component that emits CSS var declarationsvarsexposes bare CSS custom property names (same shape as the theme) for use increateGlobalStyledark mode overrides without hand-writing variable names:const { vars } = createTheme({ colors: { bg: '#fff', text: '#000' } }); const DarkOverrides = createGlobalStyle` @media (prefers-color-scheme: dark) { :root { ${vars.colors.bg}: #111; ${vars.colors.text}: #eee; } } `;Options:
prefix(default"sc"),selector(default":root", use":host"for Shadow DOM).
Minor Changes
.attrs()improvements: props supplied via attrs are now automatically made optional on the resulting component (previously required even when attrs provided a default). Also fixes a bug where the attrs callback received a mutable props object that could be changed by subsequent attrs processing; it now receives an immutable snapshot.- Removed
Dropped IE11 support: ES2015 build target, inlined unitless CSS properties (removing @emotion/unitless dependency), removed legacy React class statics from hoist and other unnecessary code.
Add
createTheme(defaultTheme, options?)for CSS variable theming that works across RSC and client components.Returns an object with the same shape where every leaf is
var(--prefix-path, fallback). Pass it toThemeProviderfor stable class name hashes across themes (no hydration mismatch on light/dark switch).const theme = createTheme({ colors: { primary: '#0070f3' } }); // theme.colors.primary → "var(--sc-colors-primary, #0070f3)" // theme.raw → original object // theme.vars.colors.primary → "--sc-colors-primary" // theme.resolve(el?) → computed values from DOM (client-only) // theme.GlobalStyle → component that emits CSS var declarationsvarsexposes bare CSS custom property names (same shape as the theme) for use increateGlobalStyledark mode overrides without hand-writing variable names:const { vars } = createTheme({ colors: { bg: '#fff', text: '#000' } }); const DarkOverrides = createGlobalStyle` @media (prefers-color-scheme: dark) { :root { ${vars.colors.bg}: #111; ${vars.colors.text}: #eee; } } `;Options:
prefix(default"sc"),selector(default":root", use":host"for Shadow DOM).Add first-class CSP nonce support. Nonces can now be configured via
StyleSheetManager'snonceprop (recommended for Next.js, Remix),ServerStyleSheet's constructor,<meta property="csp-nonce">(Vite convention),<meta name="sc-nonce">, or the legacy__webpack_nonce__global.Rearchitect
createGlobalStyleto use shared stylesheet groups.All instances of a
createGlobalStylecomponent now share a single stylesheet group, registered once at definition time. This fixes unmounting one instance removing styles needed by others (#5695), styles scattering after remount (#3146), and group ID leaks during SSR (#3022).CSS injection order is now fully determined at definition time (lower group ID = earlier in stylesheet). Render order no longer affects CSS order. Keyframes defined before a component correctly appear before that component's rules.
Also fixes: O(n^2) performance regression in jsdom test environments from unbounded rule accumulation, and stale static global styles during client-side HMR (effect deps now include the
globalStylereference so module re-evaluation triggers re-injection).Significant render performance improvements via three-layer memoization and hot-path micro-optimizations. Client-only; server renders are unaffected.
Re-renders that don't change styling now skip style resolution entirely. Components sharing the same CSS (e.g., list items) benefit from cross-sibling caching. Hot-path changes include
forEach→for/for...of, template literal → manual concat, and reduced allocations.Benchmarks vs 6.3.12:
Parent re-render (most common): 3.3x faster
First mount: 1.7-2.5x faster
Prop cycling: 2.3-2.4x faster
10K heavy layouts: 1.9x faster
No regressions on any benchmark
React Server Components support: inline style injection, deduplication, and a new
stylisPluginRSCfor child-index selector fixes.Inline style injection: RSC-rendered styled components emit
<style data-styled>tags alongside their elements. CSS is deduplicated per render viaReact.cache(React 19+). Extended components use:where()zero-specificity wrapping on base CSS so extensions always win the cascade regardless of injection order.StyleSheetManagerworks in RSC:stylisPluginsandshouldForwardPropare now applied in server component environments where React context is unavailable.stylisPluginRSC— opt-in stylis plugin that fixes:first-child,:last-child,:nth-child(), and:nth-last-child()selectors broken by inline<style>tags shifting child indices. Rewrites them using CSS Selectors Level 4of Ssyntax to exclude styled-components style tags from the count.import { StyleSheetManager, stylisPluginRSC } from 'styled-components'; <StyleSheetManager stylisPlugins={[stylisPluginRSC]}>{children}</StyleSheetManager>;The plugin rewrites
:first-child,:last-child,:nth-child(), and:nth-last-child()using CSS Selectors Level 4of Ssyntax to exclude injected style tags from the child count.Browser support: Chrome 111+, Firefox 113+, Safari 9+ (~93% global). In unsupported browsers, the entire CSS rule is dropped — only opt in if your audience supports it. Use
:first-of-type/:nth-of-type()as a universally compatible alternative.HMR: Stale styles during client-side HMR are detected and invalidated when module re-evaluation creates new component instances while IDs remain stable (SWC plugin assigns IDs by file location).
createGlobalStyleadditionally clears stale sheet entries when the instance changes between renders.The plugin is fully tree-shakeable — zero bytes in bundles that don't import it.
Patch Changes
Expose
asandforwardedAsprops inReact.ComponentPropsextraction for styled componentsFix memory leak in long-running apps using components with free-form string interpolations (e.g.
color: ${p => p.$dynamicValue}where the value comes from unbounded user input).React Native improvements: replaced postcss with a lightweight CSS declaration parser, fixing
nanoidcrashes in Expo/Metro (#5705) and improving parse speed 4-6x. Parent re-renders with unchanged children are 2.6-3.2x faster via cache-first render. Updated native component alias list (removed 5 dead components, added 4 missing). Addedreact-nativeas an optional peer dependency.Smaller install footprint via unused dependency cleanup.
6.3.12
19 Mar 2026Fix test performance regression in 6.3.x by eliminating double style rendering in
createGlobalStyleand removing unnecessary DOM queries during cleanup in client/test environments.Fix React Native crash caused by
documentreferences in the native build. The native bundle no longer includes DOM code, resolving compatibility with RN 0.79+ and Hermes.Gracefully handle CSS syntax errors in React Native instead of crashing. Missing semicolons and other syntax issues now log a warning in development and produce an empty style object instead of throwing a fatal error.
Patch Changes
Fix test performance regression in 6.3.x by eliminating double style rendering in
createGlobalStyleand removing unnecessary DOM queries during cleanup in client/test environments.Fix React Native crash caused by
documentreferences in the native build. The native bundle no longer includes DOM code, resolving compatibility with RN 0.79+ and Hermes.Gracefully handle CSS syntax errors in React Native instead of crashing. Missing semicolons and other syntax issues now log a warning in development and produce an empty style object instead of throwing a fatal error.
Preserve explicitly passed
undefinedprops instead of stripping them. This fixes compatibility with libraries like MUI and Radix UI that passundefinedto reset inherited defaults (e.g.,role={undefined}). Props set toundefinedvia.attrs()are still stripped as before.
6.3.11
19 Feb 2026Resolve "React is not defined" ReferenceError introduced in 6.3.10 when loading the CJS build in Node.js
6.3.10
18 Feb 2026RSC style tags for extended components have correct href and include base CSS
Reduce standalone/browser bundle size by making IS_RSC a build-time constant, enabling dead code elimination of RSC-specific branches
6.3.9
8 Feb 2026Fix CSS block comments containing
//(e.g. URLs) causing subsequent styles to not be applied.Fix
createGlobalStylestyles not being removed when unmounted in RSC environments. React 19'sprecedenceattribute on style tags makes them persist as permanent resources; global styles now render withoutprecedenceso they follow normal component lifecycle.In RSC environments,
themeis nowundefinedinstead of{}for styled components, matching the existing behavior ofwithThemeandcreateGlobalStyle. This ensures accessing theme properties without a ThemeProvider correctly throws rather than silently returningundefined.
Patch Changes
Fix CSS block comments containing
//(e.g. URLs) causing subsequent styles to not be applied.Fix
createGlobalStylestyles not being removed when unmounted in RSC environments. React 19'sprecedenceattribute on style tags makes them persist as permanent resources; global styles now render withoutprecedenceso they follow normal component lifecycle.In RSC environments,
themeis nowundefinedinstead of{}for styled components, matching the existing behavior ofwithThemeandcreateGlobalStyle. This ensures accessing theme properties without a ThemeProvider correctly throws rather than silently returningundefined.Fix
withThemeHOC types: ref now correctly resolves to the component instance type instead of the constructor, andthemeis properly optional in the wrapped component's props.Fix SSR styles hydration and global style cleanup in Shadow DOM
Optimize internal style processing hot paths: cached GroupedTag index lookups, string fast path in flatten, direct string concatenation in dynamic style generation, pre-built stylis middleware chain with lazy RegExp creation, single-lookup Map operations, VirtualTag append fast-path, and manual string concat in SSR output.
Revert
exportsfield and restore browser/server build split withbrowserfield in package.json. Fixesrequire('stream')resolution errors in browser bundlers like webpack 5.
6.3.8
16 Jan 2026Make react-dom an optional peer dependency, clean up some unnecessary type peers.
6.3.7
16 Jan 2026Fix createGlobalStyle compatibility with React StrictMode and RSC
This fix addresses issues where global styles would disappear or behave incorrectly in React StrictMode and RSC:
These changes ensure
createGlobalStyleworks correctly with:Restore
styled.br.Add package.json "exports" field for better native ESM integration.
6.3.6
13 Jan 2026Fix url() CSS function values being incorrectly stripped when using unquoted URLs containing
//(e.g.,url(https://example.com)). The//in protocol URLs likehttps://,http://,file://, and protocol-relative URLs was incorrectly being treated as a JavaScript-style line comment.
6.3.5
11 Jan 2026Line comments (
//) in multiline CSS declarations no longer cause parsing errors (fixes #5613)JS-style line comments (
//) placed after multiline declarations likecalc()were not being properly stripped, causing CSS parsing issues. Comments are now correctly removed anywhere in the CSS while preserving valid syntax.Example that now works:
const Box = styled.div` max-height: calc(100px + 200px + 300px); // This comment no longer breaks parsing background-color: green; `;
Contain invalid CSS syntax to just the affected line
In styled-components v6, invalid CSS syntax (like unbalanced braces) could cause all subsequent styles to be ignored. This fix ensures that malformed CSS only affects the specific declaration, not subsequent valid styles.
Example that now works:
const Circle = styled.div` width: 100px; line-height: ${() => '14px}'}; // ⛔️ This malformed line is dropped background-color: green; // ✅ Now preserved (was ignored in v6) `;
6.3.4
11 Jan 2026Fixed
createGlobalStyleto not useuseLayoutEffecton the server, which was causing a warning and broken styles in v6.3.x. The checktypeof React.useLayoutEffect === 'function'is not reliable for detecting server vs client environments in React 18+, so we now use the__SERVER__build constant instead.
6.3.3
10 Jan 2026Suppress false "created dynamically" warnings in React Server Components
The dynamic creation warning check now properly detects RSC environments and skips validation when
IS_RSCis true. This eliminates false warnings for module-level styled components in server components, which were incorrectly flagged due to RSC's different module evaluation context. Module-level styled components in RSC files no longer trigger warnings since they cannot be created inside render functions by definition.
6.3.2
10 Jan 2026Include TypeScript declaration files in npm package
Fixed Rollup TypeScript plugin configuration to override tsconfig.json's noEmit setting, ensuring TypeScript declaration files are generated during build.
Resolve TypeScript error blocking type declaration emission
Fixed TypeScript error in StyledComponent when merging style attributes from attrs. Added explicit type cast to React.CSSProperties to safely merge CSS property objects. This error was preventing TypeScript declaration files from being generated during build.
6.3.1
10 Jan 2026Ensure TypeScript declaration files are included in npm package, needed to tweak a Rollup setting.
6.3.0
10 Jan 2026Add React Server Components (RSC) support
styled-components now automatically detects RSC environments and handles CSS delivery appropriately:
RSC best practices:
const Container = styled.div``; const Button = styled.button` background: var(--color-primary, blue); `; // Variables set on parent cascade to all DOM children <Container style={{ '--color-primary': 'orchid' }}> <Button>Inherits orchid background</Button> </Container>;Technical details:
Update built-in element aliases to include modern HTML and SVG elements
Added support for modern HTML and SVG elements that were previously missing:
HTML elements:
SVG filter elements:
This ensures styled-components has comprehensive coverage of all styleable HTML and SVG elements supported by modern browsers and React.
types: Add CSS custom properties (variables) support to style prop
CSS custom properties (CSS variables like
--primary-color) are now fully supported in TypeScript without errors:
Minor Changes
Add React Server Components (RSC) support
styled-components now automatically detects RSC environments and handles CSS delivery appropriately:
No
'use client'directive required: Components work in RSC without any wrapper or directiveAutomatic CSS injection: In RSC mode, styled components emit inline
<style>tags that React 19 automatically hoists and deduplicatesZero configuration: Works out of the box with Next.js App Router and other RSC-enabled frameworks
Backward compatible: Existing SSR patterns with
ServerStyleSheetcontinue to work unchanged
RSC best practices:
Prefer static styles over dynamic interpolations to avoid serialization overhead
Use data attributes for discrete variants (e.g.,
&[data-size='lg'])CSS custom properties work perfectly in styled-components, can be set via inline
style, and cascade to children:
const Container = styled.div``; const Button = styled.button` background: var(--color-primary, blue); `; // Variables set on parent cascade to all DOM children <Container style={{ '--color-primary': 'orchid' }}> <Button>Inherits orchid background</Button> </Container>;Use build-time CSS variable generation for theming since
ThemeProvideris a no-op in RSC
Technical details:
RSC detection via
typeof React.createContext === 'undefined'ThemeProviderandStyleSheetManagerbecome no-ops in RSC (children pass-through)React hooks are conditionally accessed via runtime guards
CSS is retrieved from the StyleSheet Tag for inline delivery in RSC mode
Update built-in element aliases to include modern HTML and SVG elements
Added support for modern HTML and SVG elements that were previously missing:
HTML elements:
search- HTML5 search elementslot- Web Components slot elementtemplate- HTML template element
SVG filter elements:
All
fe*filter primitive elements (feBlend, feColorMatrix, feComponentTransfer, etc.)clipPath,linearGradient,radialGradient- gradient and clipping elementstextPath- SVG text path elementswitch,symbol,use- SVG structural elements
This ensures styled-components has comprehensive coverage of all styleable HTML and SVG elements supported by modern browsers and React.
Patch Changes
types: Add CSS custom properties (variables) support to style prop
CSS custom properties (CSS variables like
--primary-color) are now fully supported in TypeScript without errors:.attrs({ style: { '--var': 'value' } })- CSS variables in attrs<Component style={{ '--var': 'value' }} />- CSS variables in component propsMixed usage with regular CSS properties works seamlessly
Update shared css property handling tools to latest versions.
6.2.0
6 Jan 2026Experimental support for React 18+ renderToPipeableStream.
Fix no longer existing link in console debug message
Upgrade stylis to 4.3.6. Related commits
Minor Changes
Experimental support for React 18+ renderToPipeableStream.
Patch Changes
Fix no longer existing link in console debug message
Upgrade stylis to 4.3.6. Related commits
Update internal React types to ^18
Update csstype dependency from 3.1.3 to 3.2.3
This updates the pinned csstype dependency from 3.1.3 to 3.2.3 to fix a
type incompatibility with @types/react.
6.1.19
12 Jun 2025Fix for React Native >=0.79 crashes when using unsupported web-only CSS values (e.g., fit-content, min-content, max-content). The fix emits a warning and ignores the property using those values, instead of causing crashes.
6.1.18
8 May 2025Fix react 19 compatibility
Quickfix to support expo sdk >= 53 and react-native >=0.79.
6.1.17
2 Apr 2025Fix for loose
DefaultThemetype definitionAdd info link to console
6.1.16
17 Mar 2025Resolve TS error related to
ExoticComponentWithDisplayNameAPI from React.Native typings weren't on the correct folder, which caused issues on React Native projects using this library
6.1.15
5 Feb 2025Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.
6.1.14
4 Jan 2025Add changesets for release management
Prevent styled() from injecting an undefined ref prop in React 19
6.1.13
30 Aug 2024Replace deprecated global JSX namespace
Allow Passing Shadow Root as Sheet Target
6.1.12
17 Jul 2024Export rehydrate from StyleSheet
Prevent ServerStyleSheet generating empty style tags/elements
6.1.11
9 May 2024types: Add types to support third-party wrapping scenarios
6.1.9
30 Apr 2024- Security
Upgrading babel dependencies to latest to fix CVE-2023-45133
Improve types for .attrs()
types: Allow using a styled component as a key inside object styles in the web runtime
6.1.8
8 Jan 2024Revert adding
peerDependenciesfrom v6.1.7; apparently some package managers have differing behaviors aroundpeerDependenciesMeta[package].optionalwhich is causing issues. Will revisit at a later date if possible.6.1.5
27 Dec 2023Further constrain self-referencing to match v5 behavior
6.1.4
27 Dec 2023Allow using
attrsto provide a customthemeprop to child components
6.1.3
22 Dec 2023Reading the note…
6.1.2
20 Dec 2023Reading the note…
6.1.1
8 Nov 2023Reading the note…
6.1.0
14 Oct 2023native: Bump postcss version from 8.4.23 to 8.4.31
native: Solve ts warning
What's Changed
native: Bump postcss version from 8.4.23 to 8.4.31
native: Solve ts warning
6.0.9
12 Oct 2023Reading the note…
6.0.8
13 Sep 2023Reading the note…
6.0.7
3 Aug 2023Reading the note…
6.0.6
2 Aug 2023Reading the note…
6.0.5
21 Jul 2023Reading the note…
6.0.4
13 Jul 2023Reading the note…
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.