NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm, #2881 most downloaded on npm
Fast, expressive styling for React.
Latest stable
6.6.0
Last release 12 days ago
10 Nov 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 59 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
10 years old
483 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
3470387: Fix TypeScript errors in projects that augment React HTML props with a data-* template-literal index signature.
data-* template-literal index signature.Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.5.2...styled-components%406.5.3-prerelease-20260815150702
00b9ee2: .attrs() is cheaper to type-check.
00b9ee2: .attrs() is cheaper to type-check.
Two costs on the .attrs path are gone. Object-form .attrs() left the rendered target unchanged but still re-resolved that target's whole prop bag on every call, making .attrs on 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 .attrs form, with no change to the resulting component's accepted props. Redirecting the target with .attrs({ as }), including the function form, is unaffected.
00b9ee2: Explicitly annotated styled components type-check faster.
Assigning a styled component to an explicit type, as isolatedDeclarations and any package that emits .d.ts files must (const Button: IStyledComponentBase<'web', ...> = styled.button``), used to be several times more expensive to check than an inferred one, because the annotation's styleand the component's widenedstyle` were two different csstype representations that the checker compared property by property.
The inline style widening now builds on React's own CSSProperties, 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 what style accepts: CSS custom properties, a component's own narrow style, and style={undefined} all behave exactly as before.
00b9ee2: 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 take variant="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.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
00b9ee2: .attrs() is cheaper to type-check.
00b9ee2: .attrs() is cheaper to type-check.
Two costs on the .attrs path are gone. Object-form .attrs() left the rendered target unchanged but still re-resolved that target's whole prop bag on every call, making .attrs on 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 .attrs form, with no change to the resulting component's accepted props. Redirecting the target with .attrs({ as }), including the function form, is unaffected.
00b9ee2: Explicitly annotated styled components type-check faster.
Assigning a styled component to an explicit type, as isolatedDeclarations and any package that emits .d.ts files must (const Button: IStyledComponentBase<'web', ...> = styled.button``), used to be several times more expensive to check than an inferred one, because the annotation's styleand the component's widenedstyle` were two different csstype representations that the checker compared property by property.
The inline style widening now builds on React's own CSSProperties, 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 what style accepts: CSS custom properties, a component's own narrow style, and style={undefined} all behave exactly as before.
00b9ee2: 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 take variant="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.
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.5.1...styled-components%406.5.2-prerelease-20260810214005
a0a92cd: Fix a styled component silently dropping props declared as a union whose members have no prop in common, which left every one of those props
as pointed 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.a0a92cd: Fix a styled component silently dropping props declared as a union whose members have no prop in common, which left every one of those props
as pointed 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.Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.5.0...styled-components%406.5.1-prerelease-20260806232123
dfe4baf: React Native components now check style against React Native's own style types. Web-only CSS such as float, and CSS custom properties such as
dfe4baf: React Native components now check style against React Native's own style types. Web-only CSS such as float, 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 error
Web components are unaffected and still accept custom properties.
dfe4baf: Declaring your own style prop type now constrains the fields you name while leaving the rest of CSS alone. Previously a declaration like styled.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. Now width has to be a number, while color, 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 new CustomStyle helper, 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 as or forwardedAs, so it cannot be sidestepped by rendering the same component as a different tag. Note that CustomStyle removes 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 own style, passing style={undefined} explicitly is now rejected. Leaving the prop off is unaffected. Write style?: { width: number } | undefined in 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.
2949923: Large TypeScript projects type-check dramatically faster. On a 500-component app, tsc check 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 on as targets is unchanged.
dfe4baf: Fixed ref being rejected on React Native components created with the shorthand syntax, such as styled.TextInput. Passing a ref, or a ref callback whose parameter you have not annotated, now works the same way it does with styled(TextInput).
Also fixed a type error when a component's attrs callback is given an explicit parameter type, as in styled.div.attrs<MyProps>(props => props).
dfe4baf: Fixed components built on targets whose props cannot be inspected, such as Mantine's polymorphic components, rejecting children and 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.
dfe4baf: React Native components now check style against React Native's own style types. Web-only CSS such as float, and CSS custom properties such as
dfe4baf: React Native components now check style against React Native's own style types. Web-only CSS such as float, 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 error
Web components are unaffected and still accept custom properties.
dfe4baf: Declaring your own style prop type now constrains the fields you name while leaving the rest of CSS alone. Previously a declaration like styled.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. Now width has to be a number, while color, 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 new CustomStyle helper, 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 as or forwardedAs, so it cannot be sidestepped by rendering the same component as a different tag. Note that CustomStyle removes 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 own style, passing style={undefined} explicitly is now rejected. Leaving the prop off is unaffected. Write style?: { width: number } | undefined in 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.
dfe4baf: Large TypeScript projects type-check dramatically faster. On a 500-component app, tsc check 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 on as targets is unchanged.
dfe4baf: Fixed ref being rejected on React Native components created with the shorthand syntax, such as styled.TextInput. Passing a ref, or a ref callback whose parameter you have not annotated, now works the same way it does with styled(TextInput).
Also fixed a type error when a component's attrs callback is given an explicit parameter type, as in styled.div.attrs<MyProps>(props => props).
dfe4baf: Fixed components built on targets whose props cannot be inspected, such as Mantine's polymorphic components, rejecting children and 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.
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.4...styled-components%406.5.0-prerelease-20260804151232
537ea42: Reduce TypeScript type-checking cost for styled components, most noticeably styled(Component) wrappers and polymorphic as usage. Large codeba
styled(Component) wrappers and polymorphic as usage. Large codebases that saw elevated tsc memory and type-instantiation counts get lower type-check memory and time, with no change to the emitted types or runtime behavior.537ea42: Reduce TypeScript type-checking cost for styled components, most noticeably styled(Component) wrappers and polymorphic as usage. Large codeba
styled(Component) wrappers and polymorphic as usage. Large codebases that saw elevated tsc memory and type-instantiation counts get lower type-check memory and time, with no change to the emitted types or runtime behavior.Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.3...styled-components%406.4.4-prerelease-20260718230802
f692ec2: Fix a TypeScript error when wrapping a component whose props can't be statically read, such as Mantine v7's polymorphic-factory components (B
Button, Card, Menu.Item, and similar). These styled components no longer reject every prop, including children; arbitrary props are accepted again at the JSX call site and via .attrs(), while components with readable prop types stay fully type-checked.as (for example as="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.f692ec2: Fix a TypeScript error when wrapping a component whose props can't be statically read, such as Mantine v7's polymorphic-factory components (B
Button, Card, Menu.Item, and similar). These styled components no longer reject every prop, including children; arbitrary props are accepted again at the JSX call site and via .attrs(), while components with readable prop types stay fully type-checked.as (for example as="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.Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.2...styled-components%406.4.3-prerelease-20260602021501
9945904: Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
as prop under Preact's react-compat.toString on plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.as prop with a non-string type (such as Next.js Link's as?: Url). The styled component now accepts either the styled-components polymorphism value or the wrapped component's own as type, so spreading the wrapped component's props onto the styled component is assignable again.process global.d20b88e9bc16e234f5f2c2b3a7c7d7c0472d0edd Fix a TypeScript error when wrapping a component whose props include an as prop with a non-string type (such
d20b88e9bc16e234f5f2c2b3a7c7d7c0472d0edd Fix a TypeScript error when wrapping a component whose props include an as prop with a non-string type (such as Next.js Link's as?: Url). The styled component now accepts either the styled-components polymorphism value or the wrapped component's own as type, so spreading the wrapped component's props onto the styled component is assignable again.
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.2-prerelease-20260514185513...styled-components%406.4.2-prerelease-20260516150535
Internal changes only. Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.2-prerelease-20260514184
Internal changes only.
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.2-prerelease-20260514184932...styled-components%406.4.2-prerelease-20260514185513
No new changes since the previous release. (Debugging the changelog generation in the prerelease builds.)
No new changes since the previous release. (Debugging the changelog generation in the prerelease builds.)
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.2-prerelease-20260514182414...styled-components%406.4.2-prerelease-20260514184932
9945904e: Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
9945904e: Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
9945904e: Apply all chain levels' styles when an extended styled component renders with the as prop under Preact's react-compat.
9945904e: Respect a custom toString on plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.
9945904e: Fix a TypeScript error when wrapping a component whose props include an as prop with a non-string type (such as Next.js Link's as?: Url). The styled-components as and forwardedAs props now consistently override the wrapped component's same-named props instead of colliding with them.
9945904e: Restore reliable styling in production browser bundles built without a runtime process global.
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.4.1...styled-components%406.4.2-prerelease-20260514182414
49d09ae: Fix a performance regression in 6.4.0 where dynamic createGlobalStyle components caused significant re-render slowdowns. Also restores pre-6.
createGlobalStyle components caused significant re-render slowdowns. Also restores pre-6.4 cascade ordering when multiple instances of the same createGlobalStyle coexist.www.styled-components.com and described behavior from styled-components v3.Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components@6.4.1-prerelease-20260417184031...styled-components@6
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components@6.4.1-prerelease-20260417184031...styled-components@6.4.1-prerelease-20260417184545
fix: avoid double rebuildGroup on every dynamic createGlobalStyle render (#5730) by @quantizor in https://github.com/styled-components/styled-componen
Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components@6.4.0...styled-components@6.4.1-prerelease-20260417184031
b0f3d29: .attrs() improvements: props supplied via attrs are now automatically made optional on the resulting component (previously required even when
b0f3d29: .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.
2a973d8: 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.
9e07d95: 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 to ThemeProvider for 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 declarations
vars exposes bare CSS custom property names (same shape as the theme) for use in createGlobalStyle dark 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).
79cc7b4: Add first-class CSP nonce support. Nonces can now be configured via StyleSheetManager's nonce prop (recommended for Next.js, Remix), ServerStyleSheet's constructor, <meta property="csp-nonce"> (Vite convention), <meta name="sc-nonce">, or the legacy __webpack_nonce__ global.
b0f3d29: Rearchitect createGlobalStyle to use shared stylesheet groups.
All instances of a createGlobalStyle component 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 globalStyle reference so module re-evaluation triggers re-injection).
b0f3d29: 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:
9ada92b: React Server Components support: inline style injection, deduplication, and a new stylisPluginRSC for child-index selector fixes.
Inline style injection: RSC-rendered styled components emit <style data-styled> tags alongside their elements. CSS is deduplicated per render via React.cache (React 19+). Extended components use :where() zero-specificity wrapping on base CSS so extensions always win the cascade regardless of injection order.
StyleSheetManager works in RSC: stylisPlugins and shouldForwardProp are 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 4 of S syntax 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 4 of S syntax 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). createGlobalStyle additionally 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.
as and forwardedAs props in React.ComponentProps extraction for styled componentscolor: ${p => p.$dynamicValue} where the value comes from unbounded user input).nanoid crashes 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). Added react-native as an optional peer dependency.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
db4f940: Fix test performance regression in 6.3.x by eliminating double style rendering in createGlobalStyle and removing unnecessary DOM queries duri
createGlobalStyle and removing unnecessary DOM queries during cleanup in client/test environments.document references in the native build. The native bundle no longer includes DOM code, resolving compatibility with RN 0.79+ and Hermes.undefined props instead of stripping them. This fixes compatibility with libraries like MUI and Radix UI that pass undefined to reset inherited defaults (e.g., role={undefined}). Props set to undefined via .attrs() are still stripped as before.752f5ec: fix: resolve "React is not defined" ReferenceError introduced in 6.3.10 when loading the CJS build in Node.js
f674224: fix: RSC style tags for extended components have correct href and include base CSS
f674224: fix: RSC style tags for extended components have correct href and include base CSS (#5663)
<style href> attribute that caused React 19 hydration failures when using styled() inheritance<style> tag per inheritance level with content-aware hrefs, enabling React 19 deduplication of shared base stylesf674224: Reduce standalone/browser bundle size by making IS_RSC a build-time constant, enabling dead code elimination of RSC-specific branches
Nothing published for this version
ca61aca: Fix CSS block comments containing // (e.g. URLs) causing subsequent styles to not be applied.
// (e.g. URLs) causing subsequent styles to not be applied.createGlobalStyle styles not being removed when unmounted in RSC environments. React 19's precedence attribute on style tags makes them persist as permanent resources; global styles now render without precedence so they follow normal component lifecycle.theme is now undefined instead of {} for styled components, matching the existing behavior of withTheme and createGlobalStyle. This ensures accessing theme properties without a ThemeProvider correctly throws rather than silently returning undefined.withTheme HOC types: ref now correctly resolves to the component instance type instead of the constructor, and theme is properly optional in the wrapped component's props.exports field and restore browser/server build split with browser field in package.json. Fixes require('stream') resolution errors in browser bundlers like webpack 5.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
55d05c1: Make react-dom an optional peer dependency, clean up some unnecessary type peers.
51ffa9c: Fix createGlobalStyle compatibility with React StrictMode and RSC
51ffa9c: Fix createGlobalStyle compatibility with React StrictMode and RSC
This fix addresses issues where global styles would disappear or behave incorrectly in React StrictMode and RSC:
Static styles optimization: Static global styles (without props/interpolations) are now only injected once and won't be removed/re-added on every render. This prevents the style flickering that could occur during concurrent rendering.
StrictMode-aware cleanup: Style cleanup now uses queueMicrotask to coordinate with React's effect lifecycle. In StrictMode's simulated unmount/remount cycle, styles are preserved. On real unmount, styles are properly removed.
RSC compatibility: Move useRef inside RSC guard in createGlobalStyle and unify all useContext calls to use consistent !IS_RSC ? pattern.
RSC inline style tag cleanup: Fix bug where server-defined createGlobalStyle rendered in client components would leave behind accumulated SSR-rendered inline <style data-styled-global> tags. The cleanup effect now removes these hoisted style tags when the component unmounts or re-renders with different CSS.
These changes ensure createGlobalStyle works correctly with:
precedence attribute51ffa9c: Restore styled.br.
1f794b7: Add package.json "exports" field for better native ESM integration.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
189bc17: Fix url() CSS function values being incorrectly stripped when using unquoted URLs containing // (e.g., url(https://example.com)). The // in p
// (e.g., url(https://example.com)). The // in protocol URLs like https://, http://, file://, and protocol-relative URLs was incorrectly being treated as a JavaScript-style line comment.7ff7002: Fix: Line comments (//) in multiline CSS declarations no longer cause parsing errors (fixes #5613)
7ff7002: Fix: Line comments (//) in multiline CSS declarations no longer cause parsing errors (fixes #5613)
JS-style line comments (//) placed after multiline declarations like calc() 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;
`;
7ff7002: Fix: 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)
`;
8e8c282: Fixed createGlobalStyle to not use useLayoutEffect on the server, which was causing a warning and broken styles in v6.3.x. The check typeof R
createGlobalStyle to not use useLayoutEffect on the server, which was causing a warning and broken styles in v6.3.x. The check typeof React.useLayoutEffect === 'function' is not reliable for detecting server vs client environments in React 18+, so we now use the __SERVER__ build constant instead.6e4d1e7: fix: suppress false "created dynamically" warnings in React Server Components
6e4d1e7: fix: suppress false "created dynamically" warnings in React Server Components
The dynamic creation warning check now properly detects RSC environments and skips validation when IS_RSC is 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.
a4b4a6b: fix: include TypeScript declaration files in npm package
a4b4a6b: fix: include 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.
a4b4a6b: fix: 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.
046e880: Ensure TypeScript declaration files are included in npm package, needed to tweak a Rollup setting.
28fd502: Add React Server Components (RSC) support
28fd502: Add React Server Components (RSC) support
styled-components now automatically detects RSC environments and handles CSS delivery appropriately:
'use client' directive required: Components work in RSC without any wrapper or directive<style> tags that React 19 automatically hoists and deduplicatesServerStyleSheet continue to work unchangedRSC best practices:
&[data-size='lg'])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>;
ThemeProvider is a no-op in RSCTechnical details:
typeof React.createContext === 'undefined'ThemeProvider and StyleSheetManager become no-ops in RSC (children pass-through)856cf06: feat: 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 elementSVG filter elements:
fe* filter primitive elements (feBlend, feColorMatrix, feComponentTransfer, etc.)clipPath, linearGradient, radialGradient - gradient and clipping elementstextPath - SVG text path elementswitch, symbol, use - SVG structural elementsThis ensures styled-components has comprehensive coverage of all styleable HTML and SVG elements supported by modern browsers and React.
418adbe: fix(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 propsaef2ad6: Update shared css property handling tools to latest versions.
Nothing published for this version
e7c8055: Experimental support for React 18+ renderToPipeableStream.
d0b73ac: Fix no longer existing link in console debug message
8a9c21b: Upgrade stylis to 4.3.6. Related commits
a21089e: Update internal React types to ^18
c3a5990: 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.
aa997d8: fix 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
One column per quarter.