Design comparison
Solution retrospective
Hey! This is my first project where I am using tailwindcss. It was very difficult for me to switch to writing classes for styling. Should I use BEM class naming for better code readability? Any comment would be welcome!
Community feedback
- @mattari97Posted over 2 years ago
Hello. Nice one!
A little advice on tailwind. I see that you added a custom component like so
@tailwind base; @tailwind components; .btn{ @apply w-full rounded-xl p-3 mb-4 font-bold; } @tailwind utilities;
The recommended way to target a specific layer is to use the @layer directive like so:
@tailwind base; @tailwind components; @tailwind utilities; @layer components { .btn{ @apply w-full rounded-xl p-3 mb-4 font-bold; } }
This way you don't have to worry on putting your custom classes before importing the @utilities and when you'll have more custom classes it will make the code more readable. Also you can easily split your styles in multiple sheets and still import them like so:
@tailwind base; @tailwind components; @tailwind utilities; @import "custom-classes"
Peace.
Marked as helpful0
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