npm / styled-components
styled-components
What changed in styled-components 6, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-17.
9 breaking1 security1 deprecations9 new APIs and options9 performance7 behavior and defaults2 tooling50 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initstyled-components 688 changes
Breaking changes 9
Values returned by attrs now win when a caller explicitly passes the same prop as undefined. Explicit undefined props not overridden by attrs are forwarded to wrapped components, but not to DOM tags.
Server rendering with the edge runtime now fails with a clear message directing developers to use the Node.js runtime for routes that render styled-components.
Wrapping a generic polymorphic component now keeps its declared props narrow, catching invalid prop values as the direct component does.
React Native components now check style against React Native’s style types, rejecting web-only CSS and CSS custom properties that have no runtime effect.
With
exactOptionalPropertyTypes, explicitly passingstyle={undefined}is rejected on components that declare their own style prop; includeundefinedin the declaration to allow it.CSS injection order is determined at definition time rather than render order; keyframes defined before a component appear before its rules.
IE11 support is dropped and the build target is now ES2015.
In RSC environments,
themeis nowundefinedinstead of{}for styled components, so accessing theme properties without a ThemeProvider correctly throws.ThemeProvider becomes a no-op in RSC, passing children through; build-time CSS variable generation is recommended for theming.
Security 1
Instances share a stylesheet group registered at definition time, preventing one instance from removing styles needed by others and reducing SSR group ID leaks.
Deprecations 1
A development-only warning identifies differing server and browser versions, names both versions, and points to npm ls styled-components; it is stripped from production builds.
New APIs and options 9
A public type for explicitly annotating exported styled components is now exported from the web and native entries and resolves to the exact type produced by styled(Target)<Props>.
Use the new helper to make a declared style type the only accepted style fields, removing fields not listed, including CSS custom properties.
Adds CSS variable theming across RSC and client components, returning a theme-shaped object with CSS variable values, raw values, variable names, a resolver, and a GlobalStyle component.
The prefix option sets the CSS custom property prefix and defaults to "sc".
The selector option sets the CSS variable declaration selector and defaults to ":root"; use ":host" for Shadow DOM.
Adds CSP nonce support through the StyleSheetManager prop, ServerStyleSheet constructor, supported meta tags, or the legacy __webpack_nonce__ global.
Adds an opt-in Stylis plugin that rewrites child-index selectors to exclude injected style tags from the count; unsupported browsers drop the entire CSS rule.
Adds built-in aliases for modern HTML and SVG elements, including search, slot, template, SVG filter primitives, and structural elements.
Adds experimental support for React 18+ renderToPipeableStream.
Performance 9
Type-checking is faster when exported styled components have explicit types, especially for components built on intrinsic tags and wrappers over polymorphic components.
The .attrs() path requires less consumer type-check work, without changing the resulting component's accepted props.
Explicitly annotated styled components type-check faster because inline style widening now builds on React's CSSProperties.
Large TypeScript projects type-check much faster and use less peak memory, resolving some out-of-memory failures after upgrading past 6.4.2.
Reduces type-checking memory and time, especially for styled(Component) wrappers and polymorphic as usage, without changing emitted types or runtime behavior.
A lightweight CSS declaration parser replaces postcss, fixes nanoid crashes in Expo/Metro, and improves parse speed 4–6x; unchanged-child parent re-renders are also faster.
Client re-renders that do not change styling skip style resolution, with cross-sibling caching and hot-path optimizations; server renders are unaffected.
Reduce standalone/browser bundle size by making IS_RSC a build-time constant, enabling dead code elimination of RSC-specific branches.
Optimized internal style-processing hot paths, including grouped tag lookups, flattening, dynamic style generation, and SSR output.
Behavior and default changes 7
A developer-declared style prop type now constrains the fields it names while leaving other CSS accepted; constraints also hold through
asandforwardedAs.Props supplied via attrs are automatically optional on the resulting component when attrs provides a default.
React Native is now an optional peer dependency.
RSC-rendered styled components inject deduplicated inline style tags; extended components use zero-specificity wrapping on base CSS, and StyleSheetManager settings apply without React context.
react-dom is now an optional peer dependency, so projects using styled-components may not need to install it.
styled-components automatically detects RSC environments and delivers CSS through inline style tags, without requiring a use client directive or configuration.
StyleSheetManager becomes a no-op in RSC, passing children through.
Tooling 2
Adds an exports field to package.json for better native ESM integration.
TypeScript declaration files are now generated during the build and included in the npm package, making package types available to consumers.
Fixes and other changes 50
Global styles no longer disappear in React Server Components when rendered in a Suspense fallback and again in streamed content, or when shared by a layout and page during client-side navigation.
JavaScript-style // line comments are now stripped from React Native style declarations without treating URL values as comments.
The streaming API declarations no longer require a type available only in newer @types/react-dom packages; interleaveWithNodeStream retains its existing accepted inputs.
Style interpolations now run on every render, keeping hooks consistent and values read inside interpolations current. React.memo can skip renders when props are unchanged and interpolations are expensive.
Server-rendered component styles now travel with each instance in an inline style element, so styles survive when content is revealed from behind a Suspense boundary.
Published types now compile with skipLibCheck off on supported React type versions that do not declare the search HTML element; styled.search retains its existing props.
styled-components now installs the stylis type declarations its published types rely on, avoiding type-check failures when skipLibCheck is off and projects have not installed @types/stylis themselves.
Fixes TypeScript errors in projects that augment React HTML props with a data-* template-literal index signature.
Styled components now report the same debug value to React DevTools on every render, including renders that do not recompute styles.
Styled components no longer reject props declared in union members with no props in common, including when
aspoints to a component with such props. Unions whose members all have optional props are still flattened.Wrapping a component with union props no longer restricts accepted props to those common to every union member.
Targets whose props cannot be inspected no longer reject children or the target’s own props when you add a prop of your own; declared props remain strictly typed.
Reading a component’s style type now reports CSS custom properties as accepted, matching the behavior when rendering.
An
attrscallback with an explicit parameter type no longer produces a type error.Refs and unannotated ref callbacks now work on React Native components created with shorthand syntax, as they do with
styled(TextInput).Attribute autocomplete on polymorphic styled components continues to suggest props for the rendered element while typing, including when using as="video".
Styled components wrapping components whose props cannot be statically read accept arbitrary props again, including children, at JSX call sites and via .attrs(), while readable prop types remain checked.
Applies styles from every chain level when an extended styled component renders with the
asprop under Preact'sreact-compat.Allows a styled component's
asprop to accept either the styled-components polymorphism value or the wrapped component's ownastype.Restores reliable styling in production browser bundles that have no runtime
processglobal.Uses a plain value object's custom
toStringwhen interpolated, instead of walking its keys as CSS declarations.Restores prop autocomplete inside styled-component JSX after the first attribute is typed.
Fixes significant re-render slowdowns caused by dynamic createGlobalStyle components in 6.4.0.
Restores pre-6.4 cascade ordering when multiple instances of the same createGlobalStyle coexist.
Updates messages for keyframes-in-untagged-strings and component-selector references that pointed to the old website and described v3 behavior.
React.ComponentProps extraction for styled components now exposes the as prop.
The attrs callback receives an immutable snapshot so later attrs processing cannot change its props object.
Client-side HMR re-injects static global styles when module re-evaluation changes the globalStyle reference.
React.ComponentProps extraction for styled components now exposes the forwardedAs prop.
Fixes a memory leak in long-running apps when interpolation values come from unbounded user input.
Eliminates double style rendering and unnecessary DOM queries during cleanup in client/test environments, fixing a test performance regression.
In React Native, syntax errors now log a development warning and produce an empty style object instead of crashing.
The native bundle no longer includes DOM code, fixing a crash and compatibility with RN 0.79+ and Hermes.
Explicitly passed
undefinedprops are preserved for compatibility with libraries that use them to reset inherited defaults;.attrs()props set toundefinedare still stripped.Fixes a React is not defined ReferenceError when loading the CJS build in Node.js.
Fix RSC style tags for extended components: correct hrefs, include base CSS when only the extended component renders, and preserve base-before-extended CSS ordering for React 19 deduplication and specificity.
Restored the browser/server build split with the
browserfield in package.json, fixingrequire('stream')resolution errors in browser bundlers such as webpack 5.Global styles are removed when unmounted in RSC environments; they render without React 19's
precedenceattribute so they follow the normal component lifecycle.Fixed CSS block comments containing
//, such as URLs, from preventing subsequent styles from being applied.Fixed SSR styles hydration and global style cleanup in Shadow DOM.
The HOC's ref type now resolves to the component instance rather than the constructor, and
themeis optional in the wrapped component's props.Fixes global style injection and cleanup in React StrictMode and RSC, including style flickering, incorrect cleanup, and accumulated SSR-rendered inline style tags.
Restores styled.br.
Fixes unquoted URLs containing // from being incorrectly stripped, including protocol and protocol-relative URLs.
JS-style line comments after multiline CSS declarations are correctly removed, preventing CSS parsing errors.
Malformed CSS now only affects the specific declaration; subsequent valid styles are preserved.
No longer uses useLayoutEffect on the server, preventing a warning and broken styles in v6.3.x.
Module-level styled components in React Server Components no longer trigger false “created dynamically” warnings.
TypeScript now accepts CSS custom properties in style props, including in attrs and component props, alongside regular CSS properties.
Fixes a link in the console debug message that no longer exists.