Packages

styled-components

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

Your version

Where each line stands

Plan an upgrade
  • 6.x6.6.0No known advisoryLatest line
  • 5.x5.3.11No known advisoryTo 6.6.0
  • 4.x4.4.1No known advisoryTo 6.6.0
  • 3.x3.4.10No known advisoryTo 6.6.0
  • 2.x2.4.1No known advisoryTo 6.6.0
  • 1.x1.4.6No known advisoryTo 6.6.0

Latest releases

All 194 releases
  1. 6.6.0

    12 Oct 2026
    • Added a StyledComponent<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.

      StyledComponent is exported from the web and native entries. Name the target and props as you passed them to styled:

      import styled, { type StyledComponent } from 'styled-components';
      
      export const Card: StyledComponent<'div', { $active?: boolean }> = styled.div<{
        $active?: boolean;
      }>`...`;
      export const CloseButton: StyledComponent<typeof IconButton> = styled(IconButton)`...`;

      It resolves to the exact type styled(Target)<Props> produces, so the annotation is not lossy.

    • Fixed attrs no longer applying its value when a prop was explicitly passed as undefined (the 6.3.12 to 6.5.x behavior). styled.button.attrs(({ type = 'button', ...rest }) => ({ type, ...rest })) rendered without type="button" when the caller passed type={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. attrs now always wins for the keys it returns, matching every other case where a prop is passed alongside attrs.

      Also fixed: a prop passed explicitly as undefined (and not overridden by attrs) is now forwarded to a wrapped component so that component can fall back to its own default, the pattern MUI's ButtonBase relies on (for example <Root role="button" {...props} />). Wrapped components have dropped this prop entirely since v6.0, so a component that checks 'role' in props or 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 as styled.div still drops the undefined prop entirely, since browsers have no notion of an "undefined" attribute.

      If you were relying on an explicit undefined to clear an attrs default, use the function form and check for the prop's presence instead:

      styled.a.attrs(props => ('rel' in props ? {} : { rel: 'noopener' }))``;

      Passing rel={undefined} now renders no rel attribute, and omitting the prop renders rel="noopener".

      React Native already forwarded an explicit undefined prop to a wrapped component; it now also matches web in never forwarding an undefined that attrs itself produced.

    • 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 at next build or on the first request.

  2. 6.5.3

    15 Aug 2026
    • Fix TypeScript errors in projects that augment React HTML props with a data-* template-literal index signature.

  3. 6.5.2

    11 Aug 2026
    • .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.

    • 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'sstyleand 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.

    • 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.

Dependency tracking

Know when your own dependencies move

styled-components published 24 releases in the last 12 months. inlinr folds the routine ones into a line and keeps the few that need you.

  • Advisories reach you

    An email when a critical or high advisory affects a project, before the next install.

  • Upgrades checked first

    Peer ranges, Node, ESM-only and types changes read before you bump.

  • Only what matters

    Majors and breaking notes stay; patches and sibling bumps fold into one line.

How dependency tracking works

Reading releases, release notes and advisories…

Registry facts last checked 20 Nov 2026. Releases and advisories last read 20 Nov 2026.

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.