dev-resources.site
for different kinds of informations.
Tailwind tip: Managing a long list of utility classes in a single line of code
Published at
11/11/2024
Categories
tailwindcss
css
uidesign
Author
kaleemelahi
Author
11 person written this
kaleemelahi
open
Managing a long list of utility classes in a single line can become unwieldy.
Here is Tailwind's built-in feature @apply that can help make your code more readable and manageable:
Use @apply
in Custom CSS
With Tailwind's @apply directive, you can create reusable CSS classes by grouping multiple Tailwind utilities. This helps reduce the number of classes in your HTML and keeps your components more organized.
Example:
/* styles.css */
.btn-primary {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
You can then use this new .btn-primary
class in your HTML instead of repeating the Tailwind utilities:
<button class="btn-primary">Primary Button</button>
If it helped you, you can support:
https://buymeacoffee.com/kaleemelahi
uidesign Article's
30 articles in total
Ship mobile apps faster with React-Native-Blossom-UI
read article
How Thoughtful UI/UX Design Drives Digital Success (And Why Your Brand Needs It)
read article
How I built UI-Forest: Ui-Library
read article
UI Design Trends: Exploring Modern Aesthetics
read article
Color Theory in UIÂ Design
read article
The Basics of UI vs UX
read article
iPhone 16 Mockup for Figma
read article
If the setting is missing, add it yourself
read article
16 Free Resources You Should Know for Design Inspiration
read article
The Power of Design Systems: How to Create and Maintain a Consistent Design Language
read article
Designing Beautiful Dashboard Layouts with Tailwind CSS
read article
Navigating the Web Development Landscape: Finding Your Role
read article
Como o Figma Virou Parte do Meu Dia a Dia no Front-End
read article
Building Modern Websites and Managing Online Presence with Expertise in Magento, WordPress, & Shopify
read article
UI/UX Testing: Why It’s Important for Your Project
read article
Domina el arte de la personalización en Ionic: Crea paletas de colores únicas paso a paso
read article
This API Client Has A Brilliant Landing Page Trick
read article
Discover the 9 Best Open-Source Alternatives to Postman
read article
5 Tips to improve your UI Designs
read article
Transform Digital Platforms with Custom UI/UX Design Solutions
read article
Top 10 Books on Design System that i Read last year
read article
Tailwind tip: Managing a long list of utility classes in a single line of code
currently reading
Why Wireframing Matters in UI/UX Design
read article
Secrets to Designing a Great API
read article
Streamline Your API Design Workflow: Using Schemas with EchoAPI
read article
EchoAPI vs. Postman: Why EchoAPI is the Superior Choice for API Management
read article
Desizen: Empowering Designers with Practical UI/UX Challenges Introduction
read article
5 dicas de design de um front-end pra UI Designers
read article
Biometrics and Security: Designing for Trust in Web and Mobile Apps
read article
Touch-Friendly UI Design: Best Practices to Ensure Seamless Mobile Interactions
read article
Featured ones: