-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom style variation classNames #11763
Comments
Completely agree. The point about converting old code seems especially relevant. |
It's possible to get active style? |
@vicolaspetru The CSS class is applied to the block container both in the admin/editor and front-end, so registering gutenberg editor styles should be all you need to do. |
Ist der still no way to remove that 'is-style' prefix? i just need that to use bootstrap classes. |
Please add filter to remove/disable prefixes like: has- , is-style- |
Admittedly, requiring to use the is-style prefix is frustrating because we're having to change our naming structure (BEM based) for our growing pattern library/components to match Gutenberg's decisions. :/ |
As a workaround you can prepend a whitespace to your class. Then you will have a useless "is-style-" class and the class you want. |
@ecdani Tried your solution. Turns out when you change between variations, the classnames are always added, not changed. in my example i want to create a large and small paragraph. when i change default paragraph to large, |
Still no solution for this? I'd like to use my existing classes so I don't have to manage Block Editor CSS and my Global CSS ... |
You are right @jurajk . Maybe it will be useful to someone with this problem ... |
@ecdani thanks for the example. i was hoping to do this outside javascript, but it does the job nicely. |
I think, there would not be an option near future. |
I had to just use a string.replace function in the save function. This really needs to be a feature, as well as allowing custom classnames per block. The classname conventions are far too verbose for my liking, I understand why they exist, but us back end devs are not idiots and understand the reasoning, we should be allowed to make our own classes without having to jump through hoops or use hacks, it would make developing these blocks much less painless |
I agree we should have a way of opting out of these standard class names. Providing an optional I am in the same boat where we have a theme built around a design system that uses BEM naming convention, and I hate the fact that we cannot use the built-in block styles feature. It seems like a great user experience with a lot of work put into it but the class format it generates means I haven't been able to use it for any blocks. I have explored hacks to try to get it to work and even looked into building a custom style previewer but in the end I use a basic select control for blocks that really need a way to pick a variation. I feel this ties in to #41349. Having a predefined class name format might be nice when you are mixing and matching themes and blocks on a little personal site, but organizations building cohesive projects with their own blocks/themes should be able to say "we don't need our custom blocks to follow that predefined naming convention". We can see some steps toward this, like theme.json using the |
+1 want to use tailwind classes |
+1 also want to use Tailwind classes (on headless projects); currently I strip the class prefixes with JS on my decoupled front-end, which is an ugly hack. |
Is your feature request related to a problem? Please describe.
The block styles variations API introduced in #7362 uses an
is-style-{styleName}
className to the block for style variants. This works well for core blocks and new blocks, but may be overly opinionated for converting existing content that has an established approach to styling variants (see #7362 (comment)). For example, a pattern library that uses BEM conventions might use.element
for a default element, and.element.element--variant
for a variant of that element. I'd advocate for a solution that does not require changing an existing naming convention if one exists.Describe the solution you'd like
A
className
attribute could be added to each style variation which, if supplied, would be used instead of the default generated className. Here's some pseudocode:Describe alternatives you've considered
The only alternative at present is to use the opinionated
is-style-{styleName}
naming convention.The text was updated successfully, but these errors were encountered: