Packages

styled-components

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

Your version

194 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  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.

  4. 6.5.1

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

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

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

  5. 6.5.0

    4 Aug 2026
    • React Native components now check style against React Native's own style types. Web-only CSS such as float, 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.

      const Card = styled.View``;
      
      <Card style={{ padding: 16 }} />; // unchanged
      <Card style={{ float: 'left' }} />; // now a type error

      Web components are unaffected and still accept custom properties.

    • Declaring your own style prop type now constrains the fields you name while leaving the rest of CSS alone. Previously a declaration like styled.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. Now width has to be a number, while color, 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 new CustomStyle helper, which removes every field you did not list:

      const Box = styled.div<{ style?: CustomStyle<{ width: number }> }>``;

      The constraint holds when the component is rendered through as or forwardedAs, so it cannot be sidestepped by rendering the same component as a different tag. Note that CustomStyle removes 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 own style, passing style={undefined} explicitly is now rejected. Leaving the prop off is unaffected. Write style?: { width: number } | undefined in 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.

    • Large TypeScript projects type-check dramatically faster. On a 500-component app, tsc check 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 on as targets is unchanged.

  6. 6.4.4

    18 Jul 2026
    • Reduce TypeScript type-checking cost for styled components, most noticeably styled(Component) wrappers and polymorphic as usage. Large codebases that saw elevated tsc memory and type-instantiation counts get lower type-check memory and time, with no change to the emitted types or runtime behavior.

  7. 6.4.3

    24 Jun 2026
    • Fix a TypeScript error when wrapping a component whose props can't be statically read, such as Mantine v7's polymorphic-factory components (Button, Card, Menu.Item, and similar). These styled components no longer reject every prop, including children; arbitrary props are accepted again at the JSX call site and via .attrs(), while components with readable prop types stay fully type-checked.

    • Keep TypeScript attribute autocomplete working while you type props on a polymorphic styled component. When a component renders a different element through as (for example as="video"), beginning to type a new prop name could make the whole suggestion list vanish; the rendered element's props now keep autocompleting as you go.

  8. 6.4.2

    19 May 2026
    • Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.

    • Apply all chain levels' styles when an extended styled component renders with the as prop under Preact's react-compat.

    • Respect a custom toString on plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.

  9. 6.4.1

    21 Apr 2026
    • Fix a performance regression in 6.4.0 where dynamic createGlobalStyle components caused significant re-render slowdowns. Also restores pre-6.4 cascade ordering when multiple instances of the same createGlobalStyle coexist.

    • Fix outdated dev-mode error messages for keyframes-in-untagged-strings and component-selector references that still pointed at www.styled-components.com and described behavior from styled-components v3.

  10. 6.4.0

    9 Apr 2026
    • Removed

      Dropped IE11 support: ES2015 build target, inlined unitless CSS properties (removing @emotion/unitless dependency), removed legacy React class statics from hoist and other unnecessary code.

    • .attrs() improvements: props supplied via attrs are now automatically made optional on the resulting component (previously required even when attrs provided a default). Also fixes a bug where the attrs callback received a mutable props object that could be changed by subsequent attrs processing; it now receives an immutable snapshot.

    • Add createTheme(defaultTheme, options?) for CSS variable theming that works across RSC and client components.

      Returns an object with the same shape where every leaf is var(--prefix-path, fallback). Pass it to ThemeProvider for stable class name hashes across themes (no hydration mismatch on light/dark switch).

      const theme = createTheme({ colors: { primary: '#0070f3' } });
      // theme.colors.primary → "var(--sc-colors-primary, #0070f3)"
      // theme.raw → original object
      // theme.vars.colors.primary → "--sc-colors-primary"
      // theme.resolve(el?) → computed values from DOM (client-only)
      // theme.GlobalStyle → component that emits CSS var declarations

      vars exposes bare CSS custom property names (same shape as the theme) for use in createGlobalStyle dark mode overrides without hand-writing variable names:

      const { vars } = createTheme({ colors: { bg: '#fff', text: '#000' } });
      
      const DarkOverrides = createGlobalStyle`
        @media (prefers-color-scheme: dark) {
          :root {
            ${vars.colors.bg}: #111;
            ${vars.colors.text}: #eee;
          }
        }
      `;

      Options: prefix (default "sc"), selector (default ":root", use ":host" for Shadow DOM).

  11. 6.3.12

    19 Mar 2026
    • Fix test performance regression in 6.3.x by eliminating double style rendering in createGlobalStyle and removing unnecessary DOM queries during cleanup in client/test environments.

    • Fix React Native crash caused by document references in the native build. The native bundle no longer includes DOM code, resolving compatibility with RN 0.79+ and Hermes.

    • Gracefully handle CSS syntax errors in React Native instead of crashing. Missing semicolons and other syntax issues now log a warning in development and produce an empty style object instead of throwing a fatal error.

  12. 6.3.11

    19 Feb 2026
    • Resolve "React is not defined" ReferenceError introduced in 6.3.10 when loading the CJS build in Node.js

  13. 6.3.10

    18 Feb 2026
    • RSC style tags for extended components have correct href and include base CSS

    • Reduce standalone/browser bundle size by making IS_RSC a build-time constant, enabling dead code elimination of RSC-specific branches

  14. 6.3.9

    8 Feb 2026
    • Fix CSS block comments containing // (e.g. URLs) causing subsequent styles to not be applied.

    • Fix createGlobalStyle styles not being removed when unmounted in RSC environments. React 19's precedence attribute on style tags makes them persist as permanent resources; global styles now render without precedence so they follow normal component lifecycle.

    • In RSC environments, theme is now undefined instead of {} for styled components, matching the existing behavior of withTheme and createGlobalStyle. This ensures accessing theme properties without a ThemeProvider correctly throws rather than silently returning undefined.

  15. 6.3.8

    16 Jan 2026
    • Make react-dom an optional peer dependency, clean up some unnecessary type peers.

  16. 6.3.7

    16 Jan 2026
    • Fix createGlobalStyle compatibility with React StrictMode and RSC

      This fix addresses issues where global styles would disappear or behave incorrectly in React StrictMode and RSC:

      These changes ensure createGlobalStyle works correctly with:

    • Restore styled.br.

    • Add package.json "exports" field for better native ESM integration.

  17. 6.3.6

    13 Jan 2026
    • Fix url() CSS function values being incorrectly stripped when using unquoted URLs containing // (e.g., url(https://example.com)). The // in protocol URLs like https://, http://, file://, and protocol-relative URLs was incorrectly being treated as a JavaScript-style line comment.

  18. 6.3.5

    11 Jan 2026
    • Line comments (//) in multiline CSS declarations no longer cause parsing errors (fixes #5613)

      JS-style line comments (//) placed after multiline declarations like calc() were not being properly stripped, causing CSS parsing issues. Comments are now correctly removed anywhere in the CSS while preserving valid syntax.

      Example that now works:

      const Box = styled.div`
        max-height: calc(100px + 200px + 300px); // This comment no longer breaks parsing
        background-color: green;
      `;
    • Contain invalid CSS syntax to just the affected line

      In styled-components v6, invalid CSS syntax (like unbalanced braces) could cause all subsequent styles to be ignored. This fix ensures that malformed CSS only affects the specific declaration, not subsequent valid styles.

      Example that now works:

      const Circle = styled.div`
        width: 100px;
        line-height: ${() => '14px}'}; // ⛔️ This malformed line is dropped
        background-color: green; // ✅ Now preserved (was ignored in v6)
      `;
  19. 6.3.4

    11 Jan 2026
    • Fixed createGlobalStyle to not use useLayoutEffect on the server, which was causing a warning and broken styles in v6.3.x. The check typeof React.useLayoutEffect === 'function' is not reliable for detecting server vs client environments in React 18+, so we now use the __SERVER__ build constant instead.

  20. 6.3.3

    10 Jan 2026
    • Suppress false "created dynamically" warnings in React Server Components

      The dynamic creation warning check now properly detects RSC environments and skips validation when IS_RSC is true. This eliminates false warnings for module-level styled components in server components, which were incorrectly flagged due to RSC's different module evaluation context. Module-level styled components in RSC files no longer trigger warnings since they cannot be created inside render functions by definition.

  21. 6.3.2

    10 Jan 2026
    • Include TypeScript declaration files in npm package

      Fixed Rollup TypeScript plugin configuration to override tsconfig.json's noEmit setting, ensuring TypeScript declaration files are generated during build.

    • Resolve TypeScript error blocking type declaration emission

      Fixed TypeScript error in StyledComponent when merging style attributes from attrs. Added explicit type cast to React.CSSProperties to safely merge CSS property objects. This error was preventing TypeScript declaration files from being generated during build.

  22. 6.3.1

    10 Jan 2026
    • Ensure TypeScript declaration files are included in npm package, needed to tweak a Rollup setting.

  23. 6.3.0

    10 Jan 2026
    • Add React Server Components (RSC) support

      styled-components now automatically detects RSC environments and handles CSS delivery appropriately:

      RSC best practices:

      const Container = styled.div``;
      const Button = styled.button`
        background: var(--color-primary, blue);
      `;
      
      // Variables set on parent cascade to all DOM children
      <Container style={{ '--color-primary': 'orchid' }}>
        <Button>Inherits orchid background</Button>
      </Container>;

      Technical details:

    • Update built-in element aliases to include modern HTML and SVG elements

      Added support for modern HTML and SVG elements that were previously missing:

      HTML elements:

      SVG filter elements:

      This ensures styled-components has comprehensive coverage of all styleable HTML and SVG elements supported by modern browsers and React.

    • types: Add CSS custom properties (variables) support to style prop

      CSS custom properties (CSS variables like --primary-color) are now fully supported in TypeScript without errors:

  24. 6.2.0

    6 Jan 2026
    • Experimental support for React 18+ renderToPipeableStream.

    • Fix no longer existing link in console debug message

    • Upgrade stylis to 4.3.6. Related commits

  25. 6.1.19

    12 Jun 2025
    • Fix for React Native >=0.79 crashes when using unsupported web-only CSS values (e.g., fit-content, min-content, max-content). The fix emits a warning and ignores the property using those values, instead of causing crashes.

  26. 6.1.18

    8 May 2025
    • Fix react 19 compatibility

    • Quickfix to support expo sdk >= 53 and react-native >=0.79.

  27. 6.1.17

    2 Apr 2025
    • Fix for loose DefaultTheme type definition

    • Add info link to console

  28. 6.1.16

    17 Mar 2025
    • Resolve TS error related to ExoticComponentWithDisplayName API from React.

    • Native typings weren't on the correct folder, which caused issues on React Native projects using this library

  29. 6.1.15

    5 Feb 2025

    Maintenance only: docs, tests, build or refactoring. Nothing changes in how you use it.

  30. 6.1.14

    4 Jan 2025
    • Add changesets for release management

    • Prevent styled() from injecting an undefined ref prop in React 19

  31. 6.1.13

    30 Aug 2024
    • Replace deprecated global JSX namespace

    • Allow Passing Shadow Root as Sheet Target

  32. 6.1.12

    17 Jul 2024
    • Export rehydrate from StyleSheet

    • Prevent ServerStyleSheet generating empty style tags/elements

  33. 6.1.11

    9 May 2024
    • types: Add types to support third-party wrapping scenarios

  34. 6.1.10

    7 May 2024
    • Export IStyledComponentBase interface

    • Revert type changes introduced in #4288 due to a large number of bug reports

  35. 6.1.9

    30 Apr 2024
    • Security

      Upgrading babel dependencies to latest to fix CVE-2023-45133

    • Improve types for .attrs()

    • types: Allow using a styled component as a key inside object styles in the web runtime

  36. 6.1.8

    8 Jan 2024

    Revert adding peerDependencies from v6.1.7; apparently some package managers have differing behaviors around peerDependenciesMeta[package].optional which is causing issues. Will revisit at a later date if possible.

  37. 6.1.6 – 6.1.72 releases with no change for you1 dependency update, 1 without a noteShow each
    • 6.1.78 Jan 2024dependency updates
    • 6.1.627 Dec 2023no note
  38. 6.1.5

    27 Dec 2023
    • Further constrain self-referencing to match v5 behavior

  39. 6.1.4

    27 Dec 2023
    • Allow using attrs to provide a custom theme prop to child components

  40. 6.1.3

    22 Dec 2023

    Reading the note…

  41. 6.1.2

    20 Dec 2023

    Reading the note…

  42. 6.1.1

    8 Nov 2023

    Reading the note…

  43. 6.1.0

    14 Oct 2023
    • native: Bump postcss version from 8.4.23 to 8.4.31

    • native: Solve ts warning

  44. 6.0.9

    12 Oct 2023

    Reading the note…

  45. 6.0.8

    13 Sep 2023

    Reading the note…

  46. 6.0.7

    3 Aug 2023

    Reading the note…

  47. 6.0.6

    2 Aug 2023

    Reading the note…

  48. 6.0.5

    21 Jul 2023

    Reading the note…

  49. 6.0.4

    13 Jul 2023

    Reading the note…

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.