Ideas about using attributes for css selectors (AMCSS) #2
Replies: 6 comments 18 replies
-
@viT-1 Thanks for opening up a discussion tab. I have been developing Rams a CSS framework to prove that it is possible to design a website using pure data attributes for styling components instead of the industry standard CSS classes. I have discovered that data attributes are more convenient than class since they allow us to use custom names |
Beta Was this translation helpful? Give feedback.
-
The amcss system is not a valid web standard so I just use data attributes to style my components, however, I believe we should have a valid standard instead of using data attributes. Have you created anything cool using pure data attributes I would like to see? |
Beta Was this translation helpful? Give feedback.
-
I never use the Anchor[data-anchor] {
display: block;
padding: $space-y $space-x;
color: $anchor-color;
font-family: $anchor-font-family;
text-decoration: none;
cursor: pointer;
transition: $anchor-transition;
&:where([data-state="active"], :hover, :active) {
color: $anchor-active-color;
text-decoration: none;
}
&:focus {
outline: thin dotted;
outline-offset: -0.125rem;
}
} Navbar[data-navbar] {
width: 100%;
background-color: $navbar-background;
color: $navbar-anchor-text-active;
}
[data-navbar="top"],
[data-navbar="bottom"] {
z-index: 1000;
position: fixed;
}
[data-navbar="top"] {
top: 0;
:where(&) [data-dropbox] {
top: 100%;
}
}
[data-navbar="bottom"] {
bottom: 0;
:where(&) [data-dropbox] {
bottom: 100%;
}
}
[data-anchor~="navbar"] {
color: $navbar-anchor-text;
&:where([data-state="active"], :hover, :active) {
color: $navbar-anchor-text-active;
}
}
[data-dropbox~="navbar"] {
background-color: $navbar-dropbox-background;
} Flex box[data-flex] {
display: flex;
}
[data-item~="grow"] {
flex-grow: 1;
} |
Beta Was this translation helpful? Give feedback.
-
This is a valid CSS selector and it works as expected an alternative will be |
Beta Was this translation helpful? Give feedback.
-
I don't like Tailwind atomic design or classes, and I don't believe everything should be set with utility classes. I use utility data attributes to do minor adjustments, everything else is build as a component. |
Beta Was this translation helpful? Give feedback.
-
Can you show me how you will use them in an HTML file? |
Beta Was this translation helpful? Give feedback.
-
Do you use attribute selectors (especially with data-attributes)?
Beta Was this translation helpful? Give feedback.
All reactions