Contextual / Scoped Classes and Descendant Selectors for Atomic Classes #36906
ffxffxwu
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Describe the Problem
I really like the new Atomic class system in Elementor V4. However, one limitation makes it difficult to scale on larger projects: classes currently work in a flat/global namespace, without the ability to style a class differently based on its parent or context.
For example, I may have multiple modules:
.module-a .module-bEach module may contain elements with the same logical role:
.left-content .right-contentHowever, .left-content in .module-a may require completely different styling from .left-content in .module-b.
Because Atomic classes are global, I cannot safely use a generic .left-content class for both. Instead, I have to create unique classes for every module:
.module-a-left-content .module-a-right-content .module-b-left-content .module-b-right-contentThis becomes difficult to manage as a project grows.
A website with many sections, cards, components, headers, footers, forms, etc. can easily end up with hundreds of highly specific classes just to avoid naming conflicts.
This creates several problems:
The Atomic class system is already very powerful, but the flat global class structure limits its scalability for component-based websites.
Propose a Solution
I would like Atomic Classes to support contextual/scoped classes and descendant selectors, allowing a class to have different styles depending on its parent context.
For example:
`.module-a .left-content {
/* styles for left-content inside Module A */
}
.module-b .left-content {
/* different styles for left-content inside Module B */
}`
Instead of creating:
.module-a-left-content .module-b-left-contentI could create reusable structural classes such as .left-content, .title, .description, .media, etc., and style them according to their parent component.
Ideally, Elementor’s UI could allow us to select or create a parent context when editing a class.
For example:
Parent: .module-a
Child: .left-content
Which generates/styles:
.module-a .left-contentThis could eventually support other common CSS relationships as well, such as:
.module-a > .content .module-a .title .module-a:hover .title .module-a.is-active .titleThis would bring the Atomic class system closer to the flexibility of native CSS while keeping the workflow visual and accessible inside Elementor.
Additional Context
No response
Agreement
All reactions