Mohamad Kamardin portrait

Mohamad Kamardin

AI-Powered Full Stack Developer

Download CV

Tailwind CSS Tips and Tricks for Faster Development

thumbnail

Tailwind CSS has transformed how I build UIs. Its utility-first approach lets me prototype quickly while keeping production code maintainable. Here are the techniques I rely on every day.

Use @apply Sparingly

It's tempting to extract every repeated utility group into a custom class, but doing so defeats the purpose of Tailwind. Reserve @apply for truly global patterns (like buttons or form inputs) and keep one-off compositions inline.

Leverage the group Variant

The group modifier lets you style child elements based on a parent's hover, focus, or active state. This eliminates the need for complex CSS or JavaScript hover interactions in most cases — simply add group to the parent and use group-hover: on children.

Customize Your Theme

Tailwind's default theme is a great starting point, but real projects need custom colors, fonts, and spacing. Extend the theme in tailwind.config rather than overriding it. This keeps your design system consistent and makes future updates easier.

Responsive Design with Breakpoints

Tailwind's mobile-first breakpoints (sm:, md:, lg:, xl:) make responsive design intuitive. Build for mobile first, then layer on larger breakpoints. Use max-md: sparingly — sticking to a mobile-first approach reduces edge cases.

Dynamic Classes with clsx

When combining conditional classes, use clsx or tailwind-merge to keep your JSX clean. Avoid template literal strings with ternary operators — they get unreadable fast.

2026 Built by Mohamad Kamardin