Packages

styled-components

6.6.0 · 12 Oct 2026MIT14.8M / weekRepositoryHomepagenpmAtom feed

Your version

4.1.0

12 Nov 2018Where it was published

4.4.1 is the newest release of 4.x.

In short

1 deprecated2 new3 changed

  • Deprecated

    Attrs can now be passed a function (see #2200); thanks @oliverlaz for providing an early PoC PR for this!

Release note

  • Performance optimization for fully static (no function interpolation) styled-components by avoiding using ThemeConsumer since it isn't necessary,

  • Allow disabling "speedy" mode via global SC_DISABLE_SPEEDY variable,

    To make use of this, you can either set SC_DISABLE_SPEEDY in your app's entry file or use something like webpack.DefinePlugin to do it at build time:

    webpack.DefinePlugin({
      SC_DISABLE_SPEEDY: true,
    });
  • Attrs can now be passed a function (see #2200); thanks @oliverlaz for providing an early PoC PR for this!

    e.g.:

    styled.div.attrs(props => ({ 'aria-title': props.title }))``;
  • Fix the warnTooManyClasses dev helper not being totally dead code eliminated in production (see #2200)

  • Deprecated

    Deprecate functions as object keys for object-form attrs (see #2200)

    e.g.:

    styled.div.attrs({ 'aria-title': props => props.title })``; // bad
    styled.div.attrs(props => ({ 'aria-title': props.title }))``; // good

    Support for this will be removed in styled-components v5. The primary impetus behind this change is to eliminate confusion around basic functions vs styled-components vs React components provided as values in the object-form attrs constructor, each of which has different handling behaviors. The single outer function to receive the props and then return a props object is conceptually simpler.

  • The standalone CDN build is now UMD-compliant and can be used with RequireJS, etc.

  • Add pixels to unitless numbers when object interpolation is used,

  • Trying to interpolate a non-styled component into CSS is now a hard error, rather than a warning (see #2173)

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.