Repository navigation
Update dependency styled-components to v6.6.0 - #2784
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
Contributor
Author
|
|
Tick the box to add this pull request to the merge queue (same as
|
renovate
Bot
force-pushed
the
renovate/styled-components-6.x
branch
from
August 15, 2026 16:54
e968c66 to
04030aa
Compare
renovate
Bot
force-pushed
the
renovate/styled-components-6.x
branch
2 times, most recently
from
September 14, 2026 14:20
bdba4b7 to
270443a
Compare
renovate
Bot
force-pushed
the
renovate/styled-components-6.x
branch
2 times, most recently
from
September 20, 2026 03:59
b72dcdb to
8201c74
Compare
renovate
Bot
force-pushed
the
renovate/styled-components-6.x
branch
from
October 13, 2026 02:43
8201c74 to
37eca26
Compare
renovate
Bot
force-pushed
the
renovate/styled-components-6.x
branch
from
October 23, 2026 03:31
37eca26 to
df8da5b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
6.4.4→6.6.0Release Notes
styled-components/styled-components (styled-components)
v6.6.0Compare Source
Minor Changes
7ce6aea: Added aStyledComponent<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:It resolves to the exact type
styled(Target)<Props>produces, so the annotation is not lossy.Patch Changes
7afbd11: Fixedattrsno 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: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.209317c: Rendering styled-components on the server with the edge runtime (for exampleexport 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.3de03c2: 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 usingisolatedDeclarations) 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.7afbd11: Fixed a typo in theuseThemeerror message's example code (a misspelled component name in error 18), so the copy-pasted example compiles as written.7afbd11: Fixed global styles fromcreateGlobalStyledisappearing 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.
52c5f6e: 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.7afbd11: 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.1c0e309: 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.7afbd11: 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.7afbd11: Fixed the shipped types failing to compile, withskipLibCheckturned 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.7afbd11: Fixed an error inside styled-components' own type declarations, withskipLibCheckturned 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.7afbd11: 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 atnpm 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.v6.5.3Compare Source
Patch Changes
3470387: Fix TypeScript errors in projects that augment React HTML props with adata-*template-literal index signature.v6.5.2Compare Source
Patch Changes
00b9ee2:.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.00b9ee2: 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.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 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.v6.5.1Compare Source
Patch Changes
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 rejected. The same applied whenaspointed 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: 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.a0a92cd: 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.v6.5.0Compare Source
Minor Changes
dfe4baf: React Native components now checkstyleagainst 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.Web components are unaffected and still accept custom properties.
dfe4baf: Declaring your ownstyleprop 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: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.2949923: 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
dfe4baf: Fixedrefbeing 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).dfe4baf: Fixed components built on targets whose props cannot be inspected, such as Mantine's polymorphic components, rejectingchildrenand the target's own props once you added a prop of your own:Wrapping such a target without adding props already worked; adding one turned the permissiveness off. Your own declared props stay strictly typed either way.
Configuration
📅 Schedule: (in timezone Asia/Shanghai)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.