Create beautiful text decorations with Tailwind CSS classes
Tailwind Text Decoration
This generator produces utility classes that map to CSS text-decoration properties. Unlike traditional CSS, Tailwind separates decoration properties into individual, composable classes:
underline, overline, line-through for decoration typedecoration-{style} for line style (solid, dashed, wavy, etc.)decoration-{color} for line color independent of text colordecoration-{width} for line thickness (1px, 2px, 4px, 8px)underline-offset-{size} for spacing controlThis modular approach lets you mix and match properties without writing custom CSS.
Use hover states with underline-offset-2 and hover:decoration-{color} for accessible interactive elements. For more hover effects, check out the hover effect generator.
<a class="underline decoration-blue-500 hover:decoration-blue-700 underline-offset-2">
Combine line-through with muted colors for sale prices, or overline for editorial annotations. Pair with gradient text effects for enhanced visual hierarchy.
<span class="line-through decoration-red-500 text-gray-500">$99</span>
Use focus states with focus:underline and focus:decoration-{color} to indicate active inputs. The input field styler offers additional form styling options.
<input class="focus:underline focus:decoration-blue-500" />
Subtle underlines with decoration-1 and offset for section headers without overpowering content. The font generator helps complete your typography system.
<h2 class="underline decoration-gray-300 underline-offset-4">
Tailwind's text decoration utilities are generated from these CSS properties:
/* Generated CSS from Tailwind classes */
.underline { text-decoration-line: underline; }
.decoration-dashed { text-decoration-style: dashed; }
.decoration-blue-500 { text-decoration-color: #3b82f6; }
.decoration-2 { text-decoration-thickness: 2px; }
.underline-offset-2 { text-underline-offset: 2px; }
When you combine multiple classes, Tailwind applies them in order, with later classes potentially overriding earlier ones based on CSS specificity rules.
Tailwind's variant system allows decoration changes across breakpoints and states, similar to how you'd use the flexbox builder for layout variants:
md:underline applies underline only on medium screens and uphover:decoration-wavy changes style on interactiondark:decoration-gray-400 adapts to user preferencesmotion-safe:decoration-2 for reduced motion considerationsNote: The generator focuses on hover, focus, and dark variants. You can manually add responsive prefixes like md: or lg: to generated classes.
Ensure decoration colors have at least 3:1 contrast against the background, especially for underlines which are typically thinner. Tools like the shadow generator can help with visual depth.
When using focus:underline for interactive elements, ensure it's not the sole focus indicator. Combine with outline or background changes. The border animation generator offers animated focus states.
Wavy decorations and transitions may affect users with vestibular disorders. Consider using motion-reduce:decoration-solid for accessibility. The parallax effect maker includes motion preferences.
Extend the generated output with your Tailwind configuration:
// tailwind.config.js
module.exports = {
theme: {
extend: {
textDecorationColor: {
'brand': '#ff6b35',
'accent': '#00a8e8'
}
}
}
}
Use: decoration-brand or decoration-accent
// tailwind.config.js
module.exports = {
theme: {
extend: {
textDecorationThickness: {
'3': '3px',
'10': '10px',
'custom': '0.5rem'
}
}
}
}
Use: decoration-3 or decoration-custom
<p class="underline decoration-dashed decoration-blue-500">className or :class bindingspostcss.config.jsclass:underline={condition} for conditional decoration:class="{'underline': isUnderlined}"underline-offset work with overline or line-through?CSS text-underline-offset only affects underlines. For other decoration types, spacing is controlled by line-height and padding.
CSS doesn't support multiple text-decoration-line values per element in Tailwind's implementation. Use nested spans for combined effects.
text-shadow or background-clip:text?Yes, text decorations work independently of other text effects. Gradient text with decoration is fully supported. Try the gradient text tool for examples.
Wavy decorations (decoration-wavy) are supported in Chrome 89+, Firefox 70+, Safari 12.1+. Solid fallback is recommended.
transition-all - customize for performanceCreate eye-catching typography with gradient text and custom fonts.
Style hover effects and animated borders for better UX.
Control letter spacing and line height for perfect typography.