styled-components
6.6.0 · 12 Oct 2026MIT14.8M / weekRepositoryHomepagenpmAtom feed
5.3.11 is the newest release of 5.x.
In short
3 new2 fixed
Release note
New Functionality
Add
shouldForwardPropAPI (almost the same as emotion's, just a slightly different usage pattern); #3006Sometimes when composing multiple higher-order components together, it's possible to get into scenarios when multiple layers consume props by the same name. In the past we've introduced various workarounds for popular props like
"as"but this power-user API allows for more granular customization of what props are passed down to descendant component children when using thestyled()HOC wrapper.When combined with other APIs like
.attrs()this becomes a very powerful constellation of abilities.Here's how you use it:
const Comp = styled('div').withConfig({ shouldForwardProp: (prop, defaultValidatorFn) => !['filterThis'].includes(prop), })` color: red; `; render(<Comp filterThis="abc" passThru="def" />); # Renders: <div className="[generated]" passThru="def"></div>The second argument
defaultValidatorFnis what we use internally to validate props based on known HTML attributes. It's provided so you can filter exactly what props you don't wish to pass and then fall-back to the default filtering mechanism if desired.Other methods on the
styledHOC like.attrscan be chained afterwithConfig(), and before opening your template literal:const Comp = styled('div').withConfig({ shouldForwardProp: (prop, defaultValidatorFn) => !['filterThis'].includes(prop), }).attrs({ className: 'foo' })` color: red; `; render(<Comp filterThis="abc" passThru="def" />); # Renders: <div className="[generated] foo" passThru="def"></div>Thanks @stevesims and all that contributed!
Add "transient props" API; #3052
Think of transient props as a lightweight, but complementary API to
shouldForwardProp. Because styled-components allows any kind of prop to be used for styling (a trait shared by most CSS-in-JS libraries, but not the third party library ecosystem in general), adding a filter for every possible prop you might use can get cumbersome.Transient props are a new pattern to pass props that are explicitly consumed only by styled components and are not meant to be passed down to deeper component layers. Here's how you use them:
const Comp = styled.div` color: ${props => props.$fg || 'black'}; `; render(<Comp $fg="red">I'm red!</Comp>);Note the dollar sign (
$) prefix on the prop; this marks it as transient and styled-components knows not to add it to the rendered DOM element or pass it further down the component hierarchy.
Bugfixes
Fix slow SSR Rehydration for malformed CSS and increase fault-tolerance (see #3018)
Change isPlainObject (internal method) to support objects created in a different context (see #3068) thanks @keeganstreet!
Add support for the
<video disablePictureInPicture>(see #3058) thanks @egdbear!
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.