Description
Added in v3.1.0
Creates a series of classes to style text underlines using modern CSS.
Jump to the demos to see each in action, or jump to a specific underline class group:
A note about Tailwind 3's native fancy underline styles
In Tailwind 3, Tailwind introduced "fancy underline styles" to allow styling of text decoration underlines and you may choose to use those instead.
The main differences are these:
- this plugin allows you to set underline colours based off theme defined text, border and background colours - which you may find more useful than using Tailwind's colour names or hex values
-
this plugin defines the offset with
em
s and notpx
- so the apparent position of the underline is fluid with the font size and not fixed. Essentially, if you wanted your underline to be level with the bottom of the descender on the letter "g" - if you set the position with pixels and change the font size at breakpoints, you'll need to set multiple pixel values. If you useem
s, one value should see you good for all font sizes. -
this plugin's classes are prefixed with
underline-
instead ofdecoration-
, both of which seem sensible, at any rate they don't clash
Setup
Requires theme.textColor
, theme.borderColor
and/or
theme.backgroundColor
configured.
Note: theme.colors
and
theme.underlineColor
are only parsed by this plugin after
version 3.5.1
.
Output
A set up helper to make sure underline styles are applied:
A series of classes to give the underline a style:
A series of classes to define the underline skip behavior:
Two classes to use text-decoration-thickness
keywords:
A series of thickness classes, in a px
scale from 1 to pixels:
A series of offset classes, in a arbitrary scale of 0 to 20, where
1 - 0.05em
, 2 = 0.1em
and so on:
A series of negative offset classes in the same arbitrary scale of 0 to 20:
And finally, a series of colour classes based on your tailwind config color
set for textColor
, backgroundColor
and
borderColor
, for example:
Demo
Responsive, interactive demo
Underline style (text-decoration-style
)
Underline skip (text-decoration-skip-ink
)
Underline thickness (text-decoration-thickness
)
Thickness keywords
Thickness scale (in px
)
Underline offset (text-underline-offset
)
Negative offsets
Underline color (text-decoration-color
)
Underline colour takes its values from your Tailwind config colors. It
creates classes from theme.colors
and
theme.underlineColor
and also name spaced classes from
theme.textColor
, theme.borderColor
and/or
theme.backgroundColor
.
From theme.underlineColor
, using the config in this document:
From theme.colors
, using the config in this document:
And finally, from theme.textColor
,
theme.borderColor
and/or theme.backgroundColor
,
using the config in this document: