Skip to content

Component selectors no longer working with styled from @mui/material after upgrading to v6 #46102

Closed
@koen-dev

Description

@koen-dev

Steps to reproduce

Stackblitz:

I’m currently migrating from Material UI v5 to v6 and noticed that component selectors no longer work when using the styled utility from @mui/material.

Here’s a minimal reproduction of what used to work in v5:

import { styled } from '@mui/material';

const Child = styled('div')`
  color: red;
`;

const Parent = styled('div')`
  ${Child} {
    color: green;
  }
`;

export default function Example() {
  return (
    <Parent>
      <Child>Hello World</Child>
    </Parent>
  );
}

Current behavior

After upgrading to v6, Child remains red, the selector no longer applies.

Expected behavior

In v5, this correctly styled the Child green when inside Parent.

Context

If I switch the import to Emotion directly like this:

import styled from '@emotion/styled';

…the selector works again and Child becomes green as expected.

I’m using Emotion and have the SWC plugin installed. Is there something I’ve missed during the v6 migration? Do I need to add or change an importMap in the plugin config to support component selectors with MUI’s styled?

Appreciate any help or clarification, this used to work, and I’d like to stick with the MUI import for consistency and theme integration.

Your environment

npx @mui/envinfo

System:
OS: macOS 15.4.1
Binaries:
Node: 22.14.0 - /nix/store/2ribxb3gi87gj4331m6k0ydn0z90zfi7-nodejs-22.14.0/bin/node
npm: 10.9.2 - /nix/store/2ribxb3gi87gj4331m6k0ydn0z90zfi7-nodejs-22.14.0/bin/npm
pnpm: 9.12.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 127.0.6533.120
Edge: 136.0.3240.50
Safari: 18.4
npmPackages:
@emotion/react: 11.14.0 => 11.14.0
@emotion/styled: 11.14.0 => 11.14.0
@mui/icons-material: 6.4.11 => 6.4.11
@mui/material: 6.4.11 => 6.4.11
@mui/system: 6.4.11 => 6.4.11
@mui/x-date-pickers: 7.29.2 => 7.29.2
@types/react: 18.3.20 => 18.3.20
react: 18.3.1 => 18.3.1
react-dom: 18.3.1 => 18.3.1
typescript: 5.8.3 => 5.8.3

Search keywords: component selector, emotion, plugin, v6

Metadata

Metadata

Assignees

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions