[styles] className contains invalid characters
See original GitHub issue- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
CSS classes should not contains these characters i.e /()
Current Behavior 😯
Class name generated by the @material-ui/styles/styled contains some invalid characters i.e () which are attached to the DOM element.

Steps to Reproduce 🕹
Just use this component
import React, { memo } from "react";
import Paper from "@material-ui/core/Paper";
import styled from "@material-ui/styles/styled";
const MyPaper = styled(Paper)({
padding: "12px 24px"
});
const Surface = ({ children, ...props }) => (
<MyPaper {...props}>{children}</MyPaper>
);
export default memo(Surface);
Your Environment 🌎
| Tech | Version |
|---|---|
| Material-UI | 4.0.0-beta.0 |
| Material-UI Styles | 4.0.0-beta.0 |
| React | 16.8.6 |
| Browser | Chromium: 74.0.3729.108 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:16 (13 by maintainers)
Top Results From Across the Web
[styles] className contains invalid characters #15529 - GitHub
Class name generated by the @material-ui/styles/styled contains some invalid characters i.e () which are attached to the DOM element.
Read more >Which characters are valid in CSS class names/selectors?
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U ...
Read more >Which characters are valid in CSS class ... - Includehelp.com
Here, we are going to learn which characters are valid in CSS class names/selectors?
Read more >Which characters are valid in CSS class names/selectors?
A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z)/(A-Z) which is followed by any numbers, hyphens,...
Read more >CSS Quick Tip: The Valid Characters in a Custom CSS Selector
A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z) which is followed by any numbers, hyphens,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

+90% of the people are using v3 that has this old regexp logic. Let’s have more people transition to v4, see how they respond. My intuition tells me we should revert, but I can be wrong. It’s better to run this experimentation and learn from it🔬:). Let’s wait.
@oliviertassinari Here, a little demo https://codesandbox.io/s/kind-silence-k60fe
Based on what I was able to figure out is that Swiper is trying to find elements but when it is trying to search for a class
.Swiper-slide-4.WithStyles(Swiper)-slide-1but that is not even a valid selector, that is why it’s “crashing”. I tried checking it withdocument.querySelectorUPDATE: I kind of resolved my issue, I moved all my styling from
withStylesintomakeStyles.