styled-components
6.6.0 · 12 Oct 2026MIT14.8M / weekRepositoryHomepagenpmAtom feed
Upgrading styled-components From 6.4.4 to 6.6.0
5 releases in betweenevery note read
Reading releases, release notes and advisories…
Release by release
- New
Added a
StyledComponent<Target, Props>type for annotating explicitly-typed styled component exports. - New
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. - Fixed
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. - Fixed
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.
- New
- Fixed
Fix TypeScript errors in projects that augment React HTML props with a
data-*template-literal index signature.
- Fixed
- Fixed
.attrs()is cheaper to type-check. - Fixed
Explicitly annotated styled components type-check faster.
- Fixed
styled()wrapping a generic polymorphic component keeps its declared props narrow.
- Fixed
- Fixed
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 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. - Fixed
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.
- Fixed
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.
- Fixed
- New
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. - New
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. - New
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. - Fixed
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). - Fixed
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:
- New
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.