Search⌘ K
AI Features

Duplication

Explore effective techniques to manage duplication of Tailwind CSS classes. Understand how to use React components, JavaScript functions, Ruby on Rails helpers, and Tailwind's @apply directive to simplify repeated styles. This lesson helps you reduce redundancy and maintain cleaner code when using Tailwind CSS.

A common concern when we’re looking at Tailwind and the long sets of class lists is how to manage duplication. If we need to type class="text-6xl font-bold text-blue-700" for every h1, as we did in the Introduction, that’s a lot of typing that has to be consistent every time there’s an h1 heading.

Manage duplication in code

Tailwind does have a way to manage CSS class list duplication, but we’re also encouraged to see the duplication issue as part of our larger code setup, ...