NO BUG: Components Variants – Classes not working correctly (only ID-level changes work)

Browser: Chrome 110
OS: macOS / Windows / Linux / etc.

Hi everyone,

I’d like to report a bug I’m experiencing with Components Variants in Bricks 2.2.

The issue: When creating variants of a Component, class-level changes are not isolated between variants — they bleed into all other variants as well. Only ID-level changes work correctly.

Steps to reproduce:

  1. Create a Button element as a Component

  2. Create 2 variants (e.g. Primary and Secondary)

  3. In one variant, assign an ACSS class to the button (e.g. btn--primary)

  4. Switch to the other variant — the same class (btn--primary) is applied there too

Expected behavior: Each variant should maintain its own independent class assignments.

Actual behavior: A class added in one variant is applied globally across all variants of that component.

Workaround: Changing the button’s background color at the ID level works correctly and is isolated per variant. The issue is specific to class assignments.

Environment: Bricks version: 2.2

Hi Daniel,
Thanks so much for your report!

In your case, using a CSS class property is probably the way to go, as it lets you assign specific classes per instance:

Best regards,
timmse

1 Like

Thank you so much @timmse! I ended up creating the different button versions using the Global Classes feature. That said, the bug is still real. Here’s another post related to this bug: https://forum.bricksbuilder.io/t/bricks-2-2-component-variant-with-custom-class/37388

There is also another bug. I have a button element whose style I change using Global Classes — this works perfectly. However, when I assign a custom CSS class I created to the button, the Gutenberg editor displays the default style, while the frontend renders it correctly according to the custom CSS class. For example, I have a gold-colored gradient button. Gutenberg displays it as green (default style), but the frontend renders it correctly.

I’m attaching a short video recording: Zight Recording 2026-03-16 ...

The current implementation only works on the “ID-level” but we could extend it to work for classes as well.

So, this isn’t a bug, but just how it currently works. The mentioned feature/improvement request definitely has its place :+1:

PS: Regarding the Gutenberg issue, it’s still an experimental feature :gear: :factory_worker:

Could you please create a new report describing the entire process (or showing it in a screencast), so we can reproduce it? Thanks!

Dear @timmse! Thank you very much for your reply, I understand what you wrote.

I think it would definitely be a great and useful improvement if it worked with classes as well.

Sure, I will create a new report regarding the bug I mentioned.