Design comparison
Solution retrospective
I'm searching for a good naming system for my scss variables. Any recommendation or best practices ?
Any feedback welcome !
Community feedback
- @abedfetratPosted over 2 years ago
Hey! Another way you can name your SCSS color variables are by keeping the named colors e.g.
$dark-blue
and declaring new variables that are more specific e.g.$clr-text
,$clr-background
and then combining the two, for example$clr-text: $dark-blue
. Anways the way you are doing it now with the numbering at the end is good because it's easy to add more values in between.Marked as helpful1@gmagnenatPosted over 2 years agoThanks for your comment @abedfetrat ! Yes, I started using that :) calling variable from variable. That's a good one to cover different syntax. I used it for font weight for example.
$fw-400: 400; $fw-regular: $fw-400;
1 - @correlucasPosted over 2 years ago
Hello Gwenaël Magnenat, for CSS and SCSS the most used CSS Naming convention The Block, Element, Modifier methodology (commonly referred to as BEM).
Everyone said that's really good, I used only few times, since I'm working in small projects. But to work in big projects or with team is a really good tool to scalate.
See more info about it here:
http://getbem.com/introduction/
I hope it helps you bro.
1@gmagnenatPosted over 2 years agoHey @correlucas, thanks for your comment ! I'm using a bit of BEM here and I really like it :)
I'm experimenting and searching for a good transferable system for scss variables naming.
for colors for example... instead of $dark-red, $light-blue.. i'm using $primary-400, $secondary-200 depending on the brightness of the color. What system do you use regularly for naming your variables?
Best
1@correlucasPosted over 2 years ago@gmagnenat I don't know SCSS yet, I want to focus only on css/html at the moment. I tried to use BEM but annoys me that the class name are ever too long. Maybe I'll use it for bigger projects or if I work in teams. But I hate the double underscore in BEM that I did only two challenge using it, then I quit.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord