Skip to content

How would one style a component differently based on its neighbours while using Atomic CSS #432

Answered by thierryk
thierryk asked this question in Q&A
Discussion options

You must be logged in to vote

Using ACSS we can rely on the > combinator and pseudo-classes to contextually style these buttons.

In the config:

"custom": {
  "Bdrs-start": "4px 0 0 4px",
  "Bdrs-end": "0 4px 4px 0"
}

In the markup:

<div class="group">
    <button class="Bgc(blue) P(10px) Bdrs(4px) group>Bdrs(0) group>Bdrs(Bdrs-start):fc group>Bdrs(Bdrs-end):lc">button</button>
    <button class="Bgc(blue) P(10px) Bdrs(4px) group>Bdrs(0) group>Bdrs(Bdrs-start):fc group>Bdrs(Bdrs-end):lc">button</button>
    <button class="Bgc(blue) P(10px) Bdrs(4px) group>Bdrs(0) group>Bdrs(Bdrs-start):fc group>Bdrs(Bdrs-end):lc">button</button>
</div>

This way we can apply the exact same classes to all our <Button> instances—regardles…

Replies: 0 comments 1 reply

Comment options

thierryk
Jan 25, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by thierryk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant