Releases

Updating styled components is usually as simple as npm install. Only major versions have the potential to introduce breaking changes (noted in the following release notes).

styled-components@7.0.0-prerelease-20261110053101

Minor Changes

  • React Native: &:disabled and &:enabled work on iOS and Android. Each element follows its own rule for "disabled": Pressable and custom components read the disabled prop, the Touchables, Text and Switch also honor the fallbacks React Native itself reads (aria-disabled on TouchableOpacity and Text, accessibilityState.disabled on the Touchables, on Text, and on Switch on Android), and TextInput reads disabled or aria-disabled. A component of your own that shares a React Native name, such as a design system's Button, follows the custom-component rule. Props set through .attrs() count; a prop that shouldForwardProp drops does not. &:enabled matches every element that is not disabled, including View and Text. A transition does not animate a change between the two; the values switch at once. On the web, Pressable, the Touchables, Switch, Text and TextInput match the same way from disabled; an element whose rendered HTML carries aria-disabled="true" also matches &:disabled (Pressable sets that attribute from disabled, so it matches only when disabled), and accessibilityState.disabled does not. See https://styled-components.com/docs/compatibility. (native-disabled-enabled.md)
  • React Native: pseudo-classes chain on iOS and Android, such as &:active:not(:disabled) or &:hover:enabled. A chained rule applies only when every part matches, and :not() of a single pseudo-class inverts it. A chain can start with an attribute or position selector, such as &[aria-pressed='true']:hover:not(:disabled), and :not() of an attribute can follow a pseudo-class or an attribute, such as &:hover:not([data-busy]). On iOS and Android, :not() of an attribute after a position selector (&:first-child:hover:not([data-busy])) and :not() of a class (&:hover:not(.icon)) are skipped with a development warning, since native elements have no class names. In a selector list such as &:hover, & .icon, each selector is judged on its own: the supported ones apply and the rest are skipped, with a development warning outside @media, @container and @supports. See https://styled-components.com/docs/compatibility. (native-pseudo-compounds.md)
  • React Native: &:read-only and &:read-write work on iOS and Android. A TextInput is :read-write while it can be edited: not disabled, not aria-readonly, and editable by React Native's own rules (readOnly wins over editable). A custom component is :read-write only when it is not disabled and you pass readOnly={false}, or editable={true} without readOnly. On the web, a TextInput given aria-readonly={false} stays editable, as on iOS and Android. Every other element is :read-only. See https://styled-components.com/docs/compatibility. (native-read-only-read-write.md)
  • React Native: a styled TextInput accepts disabled. With disabled (or aria-disabled), the input cannot be edited or focused and is announced as disabled, whatever editable, readOnly or tabIndex say, and it matches &:disabled. The prop is typed on styled.TextInput and styled(TextInput) from styled-components/native. (native-textinput-disabled.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261108052041...styled-components%407.0.0-prerelease-20261110053101

styled-components@7.0.0-prerelease-20261108052041

Major Changes

  • A nested <StyleSheetManager> without a namespace prop uses its parent's namespace, in client and server components alike. Its styles stay scoped to the parent's container. (nested-manager-namespace.md)

    <StyleSheetManager namespace="#app">
      <StyleSheetManager plugins={[myPlugin]}>
        <Card /> {/* styled under #app */}
      </StyleSheetManager>
    </StyleSheetManager>

    To render a subtree without the namespace, such as a portal mounted outside the container, pass namespace="" to its manager. Components under a manager that inherits a namespace get different class names than under one without it.

Minor Changes

  • configureServerStyles takes a namespace, which every server component is styled under, for the whole server process: (configure-server-styles-namespace.md)

    // app/layout.tsx
    import { configureServerStyles } from 'styled-components';
    
    configureServerStyles({ namespace: '#app' });

    Both namespace and plugins are optional, and each call sets both: a call without namespace clears it. A <StyleSheetManager> inside a server component starts from this namespace; its own namespace prop replaces it, and namespace="" drops it.

    Client components take their namespace from a <StyleSheetManager> rendered on the client, such as the one in your style registry. Give that manager the same namespace, so a component rendered on both sides gets the same class.

  • View transition styles can target a styled component directly. A component that sets view-transition-name gets its own class as view-transition-class, so a rule in createGlobalStyle can name the component inside a view transition pseudo-element: (view-transition-class.md)

    const Card = styled.li`
      view-transition-name: match-element;
    `;
    
    const Transitions = createGlobalStyle`
      ::view-transition-group(*${Card}) {
        animation-duration: 400ms;
      }
    `;

    The class follows a name set on the component's own element in any state or media condition, not one set on a descendant. A view-transition-class written in a component's styles is kept as written. An extension of Card matches the rules written for Card. One that sets its own view-transition-name also matches its own rules, and gets the automatic class unless it writes a view-transition-class too.

    view-transition-class: ${Card} and container-name: ${Card} emit the component's class name, which browsers accept, so a component can be listed beside other names. An extension that sets its own container-type keeps matching @container ${Base} queries, unless it writes its own container-name. On React Native, including React Native for Web, an extension's container answers only queries that name the extension itself; see https://styled-components.com/docs/compatibility.

    CSS snapshots of components that set view-transition-name include the added view-transition-class declaration.

Patch Changes

  • A server component's styles, keyframes templates included, can hold a 'use client' export, or a value a server action received from the client, without the render throwing or a selector matching more than written. The server cannot read either one, so the part of the styles holding it is left out: one selector in a list (the whole rule when it was the only one), an at-rule, a keyframes stop, or a declaration. Every other rule still applies. In development a warning names the 'use client' export, or its module for a default export. (client-references-in-server-styles.md)

    // Card.tsx starts with 'use client'
    import { Card } from './Card';
    
    const List = styled.ul`
      ${Card} + ${Card} {
        margin-top: 8px;
      }
    `;

    Here the rule for ${Card} is left out on the server. To select Card from a server component, define the styled component in a module without 'use client'. A view-transition-class or container-name left out this way keeps the class the component gets automatically.

  • A function interpolated into keyframes, directly or as a value in a style object, is left out of the animation, and in development a warning says so. Keyframes are built once where they are defined, so there are no props or theme to call a function with. (keyframes-function-interpolation.md)

    const fade = keyframes`
      from { opacity: 1; }
      to { opacity: ${() => 0.2}; } /* left out, with a warning */
    `;

    For a theme value, interpolate the createTheme value. It follows the active theme, and one animation serves every theme:

    const theme = createTheme({ opacity: { dim: 0.2 } });
    
    const fade = keyframes`
      from { opacity: 1; }
      to { opacity: ${theme.opacity.dim}; }
    `;

    For any other value, interpolate the value itself (${0.2}), or build the keyframes inside the function that has the value.

  • Under a StyleSheetManager namespace, selectors that start at the document root apply when the namespace element is <html>. With namespace="#app" on <html id="app">: (namespace-root-selectors.md)

    const Card = styled.div`
      html.dark & {
        color: white;
      }
    `;
    
    const Transitions = createGlobalStyle`
      ::view-transition-old(root) {
        animation-duration: 200ms;
      }
    `;

    Both rules apply. html.dark & styles the card on a dark page, and the view transition rule applies to the page's transitions and to a transition started on an element inside #app. A root selector inside :is() or :where(), such as :where(html.dark) &, is prefixed like any other selector, so write it as html.dark & for it to apply. When the namespace is on a container inside the page, a rule starting at html or :root applies to nothing, so an embedded app never styles its host page. The joined form applies to a namespace made of ids, classes, attributes, or pseudo-classes with no spaces between them (#app, .app.dark, [data-app]). Any other namespace, such as main #app or div#app, is prefixed the same as every other selector.

  • A style returned from attrs reaches React Native components. (native-attrs-style.md)

    const Badge = styled.View.attrs({ style: { opacity: 0.8 } })`
      padding: 4px;
    `;
    
    <Badge style={{ backgroundColor: 'red' }} />; // padding, red background, and opacity 0.8
    • The attrs style layers over the style the component is given, so both apply and the attrs value wins a key both set, as on web.
    • The component's !important declarations still win over either.
    • Arrays and function styles (such as a Pressable's) on either side are kept, and a function style is called with the current press state.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261106173006...styled-components%407.0.0-prerelease-20261108052041

styled-components@7.0.0-prerelease-20261106173006

Patch Changes

  • @view-transition and @position-try rules are emitted as written, in components and in createGlobalStyle, including inside @media. The margin boxes inside @page (such as @top-left) and the feature value blocks inside @font-feature-values (such as @styleset) are kept with their declarations. (declaration-block-at-rules.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261105185021...styled-components%407.0.0-prerelease-20261106173006

styled-components@6.7.0-prerelease-20261106165008

Minor Changes

  • f17f6c0: configureServerStyles({ stylisPlugins }) sets the plugins every server component is styled with, for the whole server process. Call it once, at the top level of a module every server render loads first. In Next.js that's the root layout file:

    // app/layout.tsx
    import { configureServerStyles, stylisPluginRSC } from 'styled-components';
    
    configureServerStyles({ stylisPlugins: [stylisPluginRSC] });
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      // ...
    }

    It reaches every server-rendered page and nested layout, including pages prerendered at build time and pages reached by client-side navigation, which a StyleSheetManager in a shared layout does not reach. A StyleSheetManager in a server component starts from these plugins; its own stylisPlugins prop replaces them, and stylisPlugins={[]} drops them.

    It applies to server components only. Client components take their plugins from a StyleSheetManager rendered on the client, such as the one in your style registry. Make one call per app: a later call replaces an earlier one and applies to renders that start after it.

Patch Changes

  • f17f6c0: stylisPluginRSC keeps its name through a production bundle, so its class names match in development and production and it passes the plugin name check.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.1-prerelease-20261106164113...styled-components%406.7.0-prerelease-20261106165008

styled-components@6.6.1-prerelease-20261106164113

Patch Changes

  • 4bfc2cb: Referring to another component in a style (${Box}:hover { ... }) produces that component's selector for any styled component under preact/compat, and for a React.memo or function wrapper that has the styled component's statics hoisted onto it.
  • 1ddadee: Each createGlobalStyle applies its own CSS when two global styles differ only in what their functions return, including bodies that are only a function (createGlobalStyle\${() => 'html { --a: 1; }'}``). This is how a CSS reset and a color-mode style are often written together, for example xstyled's Preflight and ColorModeProvider. When both set the same property, the one mounted most recently wins, and a prop or theme update does not change which one that is.

    When several mounts of one dynamic global style render on the server, the collected styles include every one of them, not only the last.

  • 4bfc2cb: A StyleSheetManager in a server component honors namespace and enableVendorPrefixes when they are passed together with stylisPlugins={[]}, matching client components.
  • ed7b199: Server components keep their StyleSheetManager settings when several requests render at the same time on one server. A server component that awaited data could lose settings such as stylisPlugins partway through its render, so stylisPluginRSC selectors like :first-child came out unrewritten at random under load.

    A StyleSheetManager in server components that reuses the same stylisPlugins array no longer picks up the namespace or enableVendorPrefixes setting of another manager rendered before it.

  • 2a285ac: A stylis plugin without a name passed to <StyleSheetManager stylisPlugins={[...]}> now throws the documented "not named" error (#15) again. The error was being created but never thrown, so an anonymous function was accepted silently and shared its class names with the same component rendered without plugins.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.0...styled-components%406.6.1-prerelease-20261106164113

styled-components@7.0.0-prerelease-20261105185021

Major Changes

  • Splitting a block across a value and its template has been removed in favor of writing the whole block in one place. A template that leaves calc(, a string, or a bracket open for a value to close is dropped from that point, and development builds warn about it. A paren, string, or bracket that a value opens can close later in the same declaration, as in width: ${'calc('}1px${')'};. (split-block-removed.md)

Patch Changes

  • createGlobalStyle interpolations run during render, the same as interpolations on a styled component. They can call hooks such as useContext, useState, useSyncExternalStore, and use, and the global style follows what those hooks return without a prop or theme change. (global-style-interpolations-in-render.md)

    A function inside a style object counts too, as in ${{ body: { color: p => p.theme.fg } }}, and follows the theme and any hook it calls.

    A parent re-render with equal props skips the interpolations. A render on a server with no ServerStyleSheet also skips them, since nothing collects the result. In a server component, an interpolation can call only the hooks React offers there.

  • A few smaller styling fixes: (style-object-and-self-reference-fixes.md)

    • An object with no prototype, as from Object.create(null), works as a style object.
    • ${false} & + & { ... } targets the same elements as & + & { ... }.
    • On the web, a component's automatic container-name reads container-type and container-name written in a & block, so & { container-name: sidebar; } keeps your name. On React Native, write container-type outside a & block. See https://styled-components.com/docs/compatibility for the selectors React Native supports.
    • A createGlobalStyle rendered in a server component includes the keyframes it references.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261105000835...styled-components%407.0.0-prerelease-20261105185021

styled-components@7.0.0-prerelease-20261105000835

Patch Changes

  • An interpolation at the start of a statement is read the way the CSS around it reads: (component-selector-before-type.md)

    • A component keeps its place in a selector. ${Child} h2 { ... }, ${A}, ${B} { ... }, ${A} ${B} { ... }, and ${Child} /* note */ { ... } all target the component, including when a function returns it.
    • A value holding an at-rule opens that at-rule, as in ${media.tablet} { ... }.
    • A value holding a selector list scopes every selector in it, as in ${'h1, h2'} { ... }.
    • A value holding a selector stays part of the selector after it, as in ${'h2'} .x { ... } and ${'a:hover'} .x { ... }. A value spaced like a declaration applies as one, as in ${'color: red'} .x { ... }.
    • A value with no space after its colon cannot be told from a:hover. It applies as a declaration before a type selector or a component, as in ${'color:red'} h1 { ... }, and reads as a selector before a class, id, attribute, or *, as in ${'a:hover'} .x { ... }. End a mixin with ; to apply it everywhere, since babel-plugin-styled-components removes the space from a css mixin. Write a:hover h1 as one value to read it as a selector everywhere.
    • A value holding a comment before a rule applies as statements, so write a selector value with no comment in it.
    • A mixin that follows a comment applies its styles.
    • A selector written against a component stays part of it, as in ${Child}.x { ... }.
    • A selector list whose values all come out empty, as in ${false}, ${false} { ... }, writes nothing and warns in development.

    An interpolation inside a string or url() is substituted as text, as in content: "a;${x}".

    In createGlobalStyle, a mixin with no ; before a class selector keeps the rest of the global style.

    On React Native, a combinator selector, :nth-child(... of ...), an attribute selector's case flag, and an @container name can be written with a newline or tab between their parts. See https://styled-components.com/docs/compatibility for the selectors React Native supports.

  • A component keeps its other styles when an interpolation holds one of these values: (function-interpolation-any-arity.md)

    • A function declaring two or more parameters, such as (props, unused) => props.color. It is called with the render context.
    • An array, directly or returned by a function. Its items are joined as text.
    • true, directly or returned by a function. It adds nothing.
    • An object with its own toString, such as a class instance or a Date, or a bigint, directly or returned by a function. It reads as its text.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261104170554...styled-components%407.0.0-prerelease-20261105000835

styled-components@7.0.0-prerelease-20261104170554

Patch Changes

  • 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-sc with MUI X DataGrid, which calls a hook within an interpolation. (interpolations-run-every-render.md)

    Style interpolations and attrs now run on every render, on the web and on React Native, so a hook called inside one runs consistently and a value read inside one is current as of that render. A re-render with unchanged props is still skipped.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261104164812...styled-components%407.0.0-prerelease-20261104170554

styled-components@7.0.0-prerelease-20261104164812

Patch Changes

  • Each createGlobalStyle applies its own CSS when two global styles differ only in what their functions return, including bodies that are only a function (createGlobalStyle\${() => 'html { --a: 1; }'}`) and functions inside a nestedcss` helper. This is how a CSS reset and a color-mode style are often written together, for example xstyled's Preflight and ColorModeProvider. When both set the same property, the one mounted most recently wins, and a prop or theme update does not change which one that is. (global-style-function-id.md)

    When several mounts of one dynamic global style render on the server, the collected styles include every one of them, not only the last.

    A global style whose only function sits inside a nested css helper renders its CSS and updates when its props change. Unmounting one of two identical static global styles keeps their CSS in place.

  • An unquoted font-family or font name stays whole on iOS, Android, and React Native for Web. A name holding a CSS escape reads as a browser reads it, so A\42 B names the face ABB and \73 erif is the generic keyword serif. A name starting with a hyphen, such as -apple-system, is one name, and a font declaration holding one keeps its size and weight. A keyword the library matches, such as \62 old in font, reads correctly too. A value that reaches React Native as text, such as the color in color: r\65 d or border: 1px solid r\65 d, keeps the escape as written and isn't read as red, and an escape inside a unit (10\70 x) isn't read. A vendor-prefixed name in a transition, such as transition-property: -webkit-transform, opacity, reads as transform at its place in the list. A sign belongs on a number inside math, as in a browser, so calc(-pi * 1px) holds the name -pi and warns in development, while calc(-1 * pi * 1px) resolves. (native-unquoted-name-escapes.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261104154810...styled-components%407.0.0-prerelease-20261104164812

styled-components@7.0.0-prerelease-20261104154810

Patch Changes

  • An escaped & and a & inside a string stay as written in a selector, so &.\[\&\>\*\] and &[title="a & b"] match what they say. A selector whose only & is one of these is scoped under the component, as in [title="a & b"] { color: red; }. (ampersand-in-strings-and-escapes.md)
  • Malformed CSS stays inside the statement that holds it, so a typo or an interpolated value cannot consume or inject other rules in the stylesheet. (brackets-and-multiline-strings-contained.md)

    A statement a browser would read past its own end is dropped, along with everything after it in the template, and development builds log a warning naming it. These are:

    • a [ that never closes, as in &[data-open { color: red; }
    • a closer inside a block it cannot close, as in f({) or [)
    • a paren that never closes straight after an at-rule name, as in @media(min-width: 1px {
    • a /* a browser reads as an open comment, as in top: //*;
    • text ending in an unpaired backslash
    • a string with a raw line break in it, which browsers end at the line break
    • a backslash after unescaped whitespace in an unquoted url, as in url(a \)), which browsers already reject

    An interpolated value that leaves one of these open behaves the same way, except a value interpolated where a whole statement goes, as in p: q; ${value} r: s;. That drops only the value and keeps what follows it. An interpolated value that closes a [ the template opened works as written.

    A complete bracket is one value, matching browsers, so --areas: [a;b]; color: red; keeps both declarations. A selector value holding a comma, as in ${'.b, .c'} { top: 0; }, scopes each selector in it. An at-rule whose name cannot start an identifier, such as a bare @, is dropped, matching browsers.

    A string continued with a backslash before a line break is unaffected in a template. In an interpolated value, a backslash before a CR LF line break drops the string.

    A function whose name holds a backslash escape, as in \75 rl(...), might mean url(, which reads its contents differently. It works as written when it holds a plain value or a single quoted string. Any other quote, a bracket, a comment, or a nested paren or brace drops it, which in rare cases is stricter than a browser. The same applies to url( straight after &, as in &url(...), because & is part of the name only in a selector.

  • A quoted font-family or font name on iOS and Android reads its CSS escapes, so "A\"B" names the face A"B and a backslash before a line break continues the name. React Native for Web keeps sending the name as written, and the browser reads the escapes. (native-font-family-string-escapes.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261104044723...styled-components%407.0.0-prerelease-20261104154810

styled-components@7.0.0-prerelease-20261104044723

Patch Changes

  • Comments, unclosed parentheses, and unclosed strings stay contained in the statement that holds them. (comments-and-open-parens-contained.md)

    A CSS comment is removed wherever it appears, including inside a function call (calc(1px /* ) */ + 2px)) and after an escaped parenthesis in a selector (&.a\(b). Inside a function call it leaves a space, so rgb(0/**/51/**/255) reads as three numbers. An unquoted url(x/*.png) keeps its path, because a comment cannot start inside one, and a quote inside an unquoted url( opens no string, matching how browsers read it.

    A statement with a ( or a quote that never closes is dropped, along with everything after it in the template, whether the opening character is in the template or in an interpolated value. A typo such as width: calc(1px; color: red; removes those styles from its own component and cannot consume the rules of other components in the stylesheet, and development builds log a warning naming the statement. A ( closed by an interpolated value (translate(${x}${y}, where y ends in )) works as written.

    createGlobalStyle keeps all of its rules when an interpolated value holds a ; or closes a (.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261104001029...styled-components%407.0.0-prerelease-20261104044723

styled-components@7.0.0-prerelease-20261104001029

Major Changes

  • A <StyleSheetManager> in a server component styles only the server components rendered inside it. Placing one in a Next.js layout to style every page (as the v6 guidance for stylisPluginRSC suggested) has been removed in favor of configureServerStyles, a one-line call at the top of the root layout file: (rsc-layout-manager-reach.md)

    // app/layout.tsx
    import { configureServerStyles } from 'styled-components';
    import { rscPlugin } from 'styled-components/plugins';
    
    configureServerStyles({ plugins: [rscPlugin] });

    If you upgrade from v6 with a layout manager such as <StyleSheetManager stylisPlugins={[stylisPluginRSC]}>, move its plugins into configureServerStyles; otherwise its plugins stop reaching your pages and :first-child / :nth-child selectors count the inline style tags again.

Minor Changes

  • configureServerStyles({ plugins }) sets the plugins every server component is styled with, for the whole server process. Call it once, at the top level of a module every server render loads first. In Next.js that's the root layout file: (configure-server-styles.md)

    // app/layout.tsx
    import { configureServerStyles } from 'styled-components';
    import { rscPlugin } from 'styled-components/plugins';
    
    configureServerStyles({ plugins: [rscPlugin] });
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      // ...
    }

    It reaches every server-rendered page and nested layout, including pages prerendered at build time and pages reached by client-side navigation. A <StyleSheetManager> inside a server component starts from these plugins; its own plugins prop replaces them, and plugins={[]} drops them.

    It applies to server components only. Client components take their plugins from a <StyleSheetManager> rendered on the client, such as the one in your style registry. Make one call per app: a later call replaces an earlier one and applies to renders that start after it. Next.js instrumentation.ts is not a reliable place for it, because Next.js does not run it while prerendering pages at build time.

Patch Changes

  • A styled component rendered as an item of an async iterable (such as an async generator) in a server component renders in development builds instead of throwing "Cannot read properties of null (reading 'useDebugValue')". (rsc-async-iterable-dev.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261103232803...styled-components%407.0.0-prerelease-20261104001029

styled-components@7.0.0-prerelease-20261103232803

Patch Changes

  • A development-only warning fires when a css fragment that carries its own declarations or rules is interpolated right after a declaration that is missing its trailing ;: (fragment-missing-semicolon-warning.md)

    const Box = styled.div`
      margin: 0 ${10}px ${css`
          color: red;`};
    `;

    Without the ;, the fragment text is read as part of the margin value, which is not valid CSS. The warning names the spot and asks for a ; before the ${...} interpolation. Value-position fragments (border: ${frag};) interpolate into the value as usual and do not warn.

  • The browser bundle is about 1 kB smaller gzipped, with the same styling behavior. (smaller-browser-bundle.md)

    Internal fields of the stylesheet and style objects have been removed from the published type declarations. None of them were documented or usable from app code.

    In object styles, a numeric value whose key is a built-in object name such as constructor gets px like any other unknown property. No CSS property has such a name.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261103190130...styled-components%407.0.0-prerelease-20261103232803

styled-components@7.0.0-prerelease-20261103190130

styled-components@7.0.0-prerelease-20261103183817

Patch Changes

  • Interpolated values stay inside their component's styles, including in templates that contain comments. An unmatched } in an interpolated value and the rest of its statement are dropped, so a value like red; } body { background: red } cannot add a global rule. (component-scope-escape.md)

    An interpolated value that nests blocks thousands of levels deep no longer crashes rendering; the over-deep block is dropped and the rest of the component's styles apply.

    Templates with a very large number of comments are processed in time proportional to their length.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261103050550...styled-components%407.0.0-prerelease-20261103183817

styled-components@7.0.0-prerelease-20261103050550

Minor Changes

  • Added a StyledComponent<Target, Props> type for annotating explicitly-typed styled component exports. (public-styled-component-annotation.md)

    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.

Patch Changes

  • Fixed attrs not applying its value when a prop was explicitly passed as undefined. styled.button.attrs({ type: 'button' }) now renders type="button" for <Button type={undefined} />, including through a wrapper component that spreads its own props over the styled component. attrs always wins for the keys it returns, on web and React Native. (attrs-win-over-undefined.md)

    Also fixed: a prop passed explicitly as undefined (and not set 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} />). A DOM tag such as styled.div still drops the prop, since browsers have no "undefined" attribute. A component that checks 'role' in props may see the key where it did not before.

    To let a caller's undefined clear an attrs default, use the function form and check for the prop:

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

    rel={undefined} then renders no rel, and omitting the prop renders rel="noopener".

  • Fix TypeScript errors in projects that augment React HTML props with a data-* template-literal index signature. (fuzzy-ravens-smile.md)
  • In development, a console warning now appears when the browser finds server-rendered styles from a different styled-components version than the one running. Those styles were previously skipped without notice, which left class names stale and hydration mismatched. Make sure the server and the browser load the same version (npm ls styled-components lists duplicates). (hydration-version-mismatch-warning.md)
  • Fixed a protocol-relative value after a colon being removed as a // line comment. --cdn: //cdn.example.com/x.png; now keeps its value, with or without spaces between the colon and the slashes. A // on a later line than the colon is still removed as a comment. (protocol-relative-value-after-colon.md)
  • styled() wrapping a generic polymorphic component keeps its declared props narrow. (styled-generic-polymorphic-narrows-props.md)

    Wrapping a component whose props are generic over an element type, such as the common <C extends React.ElementType>(props: PolymorphicProps<C, OwnProps>) pattern, 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.

  • Fixed errors inside styled-components' own type declarations, with skipLibCheck turned off, for projects without @types/react-dom or @types/node installed. The ServerStyleSheet streaming API's types referenced types that only those packages provide. interleaveWithNodeStream still accepts the result of renderToPipeableStream and Node readable streams exactly as before, and with @types/node installed it still returns a full Node stream type. (types-server-stream-without-react-dom-types.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261103032356...styled-components%407.0.0-prerelease-20261103050550

styled-components@7.0.0-prerelease-20261103032356

Patch Changes

  • On react-native-web, onAnimationEnd and onTransitionEnd on a styled React Native primitive run when that element's CSS animation or transition finishes. They run on primitives whose ref is the DOM element, including View and Text, and on FlatList, SectionList, and VirtualizedList. They do not run on KeyboardAvoidingView; put the callback on a styled View inside it. (long-cameras-fail.md)

    The callback receives { animationName, elapsedTime } or { propertyName, elapsedTime }, the same as on iOS and Android. elapsedTime is in seconds and does not include animation-delay or transition-delay. propertyName is the camelCase style name, so a transition on background-color is reported as backgroundColor. A completion on a child does not call the parent's callback, and a completion on a pseudo-element does not call it either.

  • Development builds warn when two different plugins used with <StyleSheetManager> share a name under the same namespace. The message names the shared name and tells you to give each plugin its own name. (plugin-name-collision.md)

    Plugins that share a name under the same namespace produce the same class, on the client, in server rendering, and in server components. The first subtree to render supplies the CSS for every subtree using that name. Production builds do not emit this warning. Plugins with one name under different namespaces produce different classes and do not warn.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261019010252...styled-components%407.0.0-prerelease-20261103032356

styled-components@7.0.0-prerelease-20261019010252

styled-components@7.0.0-prerelease-20261019004440

Patch Changes

  • Numbers for gridArea and lineClamp in object styles render without a unit, the same way React's inline style prop renders them: (unitless-grid-area-line-clamp.md)

    const Item = styled.div({ gridArea: 2, lineClamp: 3 });
    // grid-area: 2; line-clamp: 3;

    Components that set either property to a number get a new class name on upgrade, since the emitted CSS changes.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261012235500...styled-components%407.0.0-prerelease-20261019004440

styled-components@6.6.0

Minor Changes

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

Patch Changes

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

  • 209317c: 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.
  • 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 using isolatedDeclarations) rely on. The improvement is largest in codebases that annotate many components built on intrinsic tags such as styled.div, styled.span, and styled.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, and as polymorphism all behave exactly as before. This is purely a type-check speedup.

  • 7afbd11: Fixed a typo in the useTheme error message's example code (a misspelled component name in error 18), so the copy-pasted example compiles as written.
  • 7afbd11: Fixed global styles from createGlobalStyle disappearing 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-sc with 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.memo to 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 example url(http://example.com/image.png) or an unquoted https:// 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 (including cacheComponents). 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 (the stylisPlugins option and stylisPluginRSC), and stylis ships no types of its own. With skipLibCheck turned off, a project that had not installed @types/stylis itself could fail to type-check with an error inside styled-components' declarations. Nothing changes at runtime.

  • 7afbd11: Fixed the shipped types failing to compile, with skipLibCheck turned off, against @types/react 16, 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.search is 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, with skipLibCheck turned off, for projects using React 16 or 17 type packages or without @types/react-dom installed. The ServerStyleSheet streaming API's types referenced a type that only @types/react-dom 18 and later provide. interleaveWithNodeStream still accepts the result of renderToPipeableStream and 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 at npm ls styled-components to 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.

styled-components@7.0.0-prerelease-20261012235500

Patch Changes

  • Development warnings say what to do about the problem they report. Each one names the construct that triggered it and ends with a concrete fix, for example "Wrap the tree in a <ThemeProvider theme={...}> or pass a theme prop." for withTheme, or "Load the stylesheet with a <link> tag instead" for @import inside createGlobalStyle. Production builds are unaffected; these messages only appear in development. (warnings-name-a-fix.md)

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20261012182411...styled-components%407.0.0-prerelease-20261012235500

styled-components@7.0.0-prerelease-20261012182411

styled-components@7.0.0-prerelease-20261012164616

Patch Changes

  • Server rendering on the edge runtime is not supported. On a route with export const runtime = 'edge', a server component using styled-components fails next build, and a client component rendered through a ServerStyleSheet registry fails on the request, each with an error naming the fix: remove that line, or set it to 'nodejs', on every route that renders styled-components on the server. (edge-runtime-error.md)
  • The published package no longer ships a stray copy of the React Native development dependencies under native/node_modules, which made the install roughly 60 MB larger than the library itself. It also drops test-utils/, the repository's own test helpers, which import modules the package does not include and so could not be loaded from an install. (native-node-modules-pack.md)
  • Fixed styles from server components and createGlobalStyle disappearing when React reveals content from behind a <Suspense> boundary, or when a navigation swaps one sibling route for another. A component first rendered inside a loading fallback, or a global style mounted by both a layout and its page, could end up with a class name but no matching rule, or with no global styles at all. (rsc-suspense-style-removal.md)

    Every server-rendered styled component and global style carries the rules it needs, so no instance depends on another surviving. The data React sends to the browser includes each distinct style once.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%407.0.0-prerelease-20260925191055...styled-components%407.0.0-prerelease-20261012164616

styled-components@6.6.0-prerelease-20261012163214

Patch Changes

  • 209317c: 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.
  • 209317c: 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 (including cacheComponents). 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.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.0-prerelease-20260925231434...styled-components%406.6.0-prerelease-20261012163214

styled-components@7.0.0-prerelease-20260925191055

styled-components@6.6.0-prerelease-20260925231434

Patch Changes

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

  • 7afbd11: Fixed a typo in the useTheme error message's example code (a misspelled component name in error 18), so the copy-pasted example compiles as written.
  • 7afbd11: Fixed global styles from createGlobalStyle disappearing 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.

  • 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 example url(http://example.com/image.png) or an unquoted https:// value in a custom property) is left untouched.
  • 7afbd11: 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 (including cacheComponents). 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. Nearby duplicates still 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 collapsing into a shared class, 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 (the stylisPlugins option and stylisPluginRSC), and stylis ships no types of its own. With skipLibCheck turned off, a project that had not installed @types/stylis itself could fail to type-check with an error inside styled-components' declarations. Nothing changes at runtime.

  • 7afbd11: Fixed the shipped types failing to compile, with skipLibCheck turned off, against @types/react 16, 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.search is 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, with skipLibCheck turned off, for projects using React 16 or 17 type packages or without @types/react-dom installed. The ServerStyleSheet streaming API's types referenced a type that only @types/react-dom 18 and later provide. interleaveWithNodeStream still accepts the result of renderToPipeableStream and 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 at npm ls styled-components to 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.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.0-prerelease-20260908162735...styled-components%406.6.0-prerelease-20260925231434

styled-components@7.0.0-prerelease-20260908195050

styled-components@7.0.0-prerelease-20260908153432

styled-components@6.6.0-prerelease-20260908162735

Patch Changes

  • 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 (including cacheComponents). 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. Identical rules compress away under gzip, so the extra output is negligible; only a very large repeated list (thousands of instances of one component on a single page) is worth collapsing into a shared class, and a development-only warning points that out if it happens.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.0-prerelease-20260905051044...styled-components%406.6.0-prerelease-20260908162735

styled-components@6.6.0-prerelease-20260905051044

Patch Changes

  • 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-sc with 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.memo to 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.

Full Changelog: https://github.com/styled-components/styled-components/compare/styled-components%406.6.0-prerelease-20260817175248...styled-components%406.6.0-prerelease-20260905051044