Design comparison
Solution retrospective
Hello everyone,
I'd like to ask some questions related to the challenges I'm facing with complex components in my TailwindCSS and Nuxt 3 project. Your advice and insights would be greatly appreciated:
-
How can one optimize the use of classes in TailwindCSS when dealing with Complex components?
-
Is there a better approach to combining classes and TailwindCSS, as illustrated in the provided examples?
- Example 1
class="h-full xs:h-auto grid place-items-center shadow-xl hover:shadow-2xl transition-shadow w-full max-w-[320px] bg-white px-4 pt-4 pb-10 xs:rounded-[20px]"
- Example 2
.desc { font-family: "Outfit", sans-serif; font-style: normal; font-weight: 400; font-size: 15px; line-height: 19px; text-align: center; letter-spacing: 0.1875px; color: #7d889e; }
- Example 3
.decoration-oval { @apply rounded-full absolute; width: 270px; height: 270px; transition: all ease 0.3s; background: #3685ff; }
- Example 1: Long class (directly within the HTML element)\
- Example 2: Defining a class (considered best but inconsistent)\
- Example 3: Combination of class and Tailwind (also inconsistent)
Are there other ways to address the shortcomings in each provided example?
-
How can one ensure consistency when using TailwindCSS?
-
Are there any recommendations or guidelines on best practices when using TailwindCSS, especially when it comes to more complex components?
Community feedback
- @BrianUribe6Posted over 1 year ago
hi, I liked the animations it looks pretty cool. A small bug is that at screen sizes < 318 the background dissappears. You should consider adding the background starting from the smallest screen size. Also add a padding on the whole container to prevent the card from hitting the screen edges as the screen gets smaller.
Finally, I noticed you are using using "xs" breakpoints, I'm assuming this is for targetting the smallest screen size. Although there are places where this is useful, in general you should start building from the smallest screen size, and as the screen gets bigger you override or add new properties. if you follow this approach, you'll notice you will use fewer CSS classes, and have an easier time overall.
Marked as helpful0@dimar-hanungPosted over 1 year ago@BrianUribe6
Hi, Thanks for feedback and review my code solution!, "in general you should start building from the smallest screen size" ah yes, i forgot if tailwind is mobile first, This is a new insight to try slicing with a mobile first approach.
"I'm assuming this is for targetting the smallest screen size." you are right, at that time I was confused whether it is better to reduce the padding or remove the background
thanks for insight!
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