Are BEM-style class names possible?
See original GitHub issueHi.
I want to get classes like Card
and Card--large
.
In the documentation I found an example like this:
const Card = styled('form')`
width: 150px;
height: 120px;
&.large {
width: 300px;
height: 240px;
}
`;
// …
return (<Card large />);
It will generate somethins like this:
<form class="UserCard-Card--3mYhX UserCard-Card--2O_am"></form>
with webpack config
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: "style-loader",
},
{
loader: "astroturf/css-loader",
options: {
modules: true,
localIdentName: '[name]--[hash:base64:5]',
},
}
],
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ['babel-loader', 'astroturf/loader'],
}
]
},
But is there any way to get canonical BEM .Card
and .Card--large
classes?
<form class="Card__3mYhX Card--large__3mYhX"></form>
Regards. Anton.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Naming
Block names may consist of Latin letters, digits, and dashes. To form a CSS class, add a short prefix for namespacing: .block, Any...
Read more >BEM by Example: Best Practices for BEM CSS Naming
BEM (which stands for Block-Element-Modifier) is a naming convention standard for CSS class names. It has fairly wide adoption and is immensely ...
Read more >Class naming 101: BEM
Naming elements is just as easy as naming blocks. We create element class names by starting with the block, then adding two underscores, ......
Read more >Naming convention / Methodology / BEM
The primary purpose of the naming convention is to give names meaning so that they are as informative as possible for the developer....
Read more >BEM 101
The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS.
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 FreeTop 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
Top GitHub Comments
@taion Actually, no, sir. I think you got the problem wrong. How I should set modifier class?
Just wouldn’t work. As you may see in the config example — I am aware of localIdentName property. But if I am wrong and I may somehow configure it to get what i need — please, show me how.
Regards.
@jquense css`` with localIdentName: ‘[local]’, is totally the solution. Thanks.