Text
Text alignment, transform, decoration, and truncation utilities.
Text Alignment
Align text within its container using text-{side} classes. All alignment utilities include full responsive variants.
text-left - The quick brown fox jumps over the lazy dog.
text-center - The quick brown fox jumps over the lazy dog.
text-right - The quick brown fox jumps over the lazy dog.
text-justify - The quick brown fox jumps over the lazy dog. Sphinx of black quartz, judge my vow. How vexingly quick daft zebras jump.
<p class="text-left">Left aligned</p>
<p class="text-center">Centered</p>
<p class="text-right">Right aligned</p>
<p class="text-justify">Justified</p>
| Class | Properties | Description |
|---|---|---|
text-left | text-align: left | Align to the left |
text-center / center | text-align: center | Center alignment |
text-right | text-align: right | Align to the right |
text-justify | text-align: justify | Justify to both edges |
text-start | text-align: start | Logical start (RTL-aware) |
text-end | text-align: end | Logical end (RTL-aware) |
Responsive variants. Prefix any alignment class with a breakpoint to apply it conditionally - e.g. text-left md:text-center is left-aligned on mobile and centered from tablet up.
Text Transform
Change the visual case of text without altering the underlying HTML.
uppercase - The quick brown fox
LOWERCASE - THE QUICK BROWN FOX
capitalize - the quick brown fox
no-case - RESETS any transform (text-transform: none)
<p class="uppercase">The quick brown fox</p>
<p class="lowercase">THE QUICK BROWN FOX</p>
<p class="capitalize">the quick brown fox</p>
<p class="no-case">reset transform</p>
| Class | Properties | Description |
|---|---|---|
uppercase | text-transform: uppercase | All uppercase characters |
lowercase | text-transform: lowercase | All lowercase characters |
capitalize | text-transform: capitalize | First letter of each word capitalized |
no-case | text-transform: none | Remove any text transform |
upperfirst | ::first-letter { text-transform: uppercase } | Only the first letter of the block |
Text Decoration
Add or remove decorative lines from text. Decoration classes can be combined with color and style modifiers.
underline - The quick brown fox
overline - The quick brown fox
strike - The quick brown fox
deleted - The quick brown fox
d-none - removes decoration (applied after underline here)
<p class="underline">Underlined text</p>
<p class="overline">Overlined text</p>
<p class="strike">Strikethrough text</p>
<p class="d-none">No decoration</p>
<!-- Combine with color -->
<p class="underline underline-primary">Primary colored underline</p>
<!-- Combine with style -->
<p class="underline underline-wavy">Wavy underline</p>
<p class="underline underline-dashed">Dashed underline</p>
| Class | Properties | Description |
|---|---|---|
underline | text-decoration: underline | Underline |
overline | text-decoration: overline | Line above text |
strike | text-decoration: line-through | Strikethrough |
deleted | text-decoration: line-through | Deleted / struck text |
d-none | text-decoration: none | Remove decoration |
Decoration color & style modifiers
Combine decoration classes with color and style suffixes. Any theme color can be used as a suffix (e.g. underline-primary, strike-danger). Style suffixes: solid, double, dotted, dashed, wavy.
<!-- Color modifiers -->
<span class="underline underline-primary">Primary</span>
<span class="underline underline-success">Success</span>
<span class="underline underline-danger">Danger</span>
<!-- Style modifiers -->
<span class="underline underline-wavy">Wavy</span>
<span class="underline underline-dotted">Dotted</span>
Line Clamp
Truncate multi-line text to a fixed number of lines with an ellipsis. Uses -webkit-line-clamp under the hood, widely supported in all modern browsers.
line-clamp-2
The quick brown fox jumps over the lazy dog. Sphinx of black quartz, judge my vow. How vexingly quick daft zebras jump. The five boxing wizards jump quickly. Pack my box with five dozen liquor jugs. Jackdaws love my big sphinx of quartz.
line-clamp-3
The quick brown fox jumps over the lazy dog. Sphinx of black quartz, judge my vow. How vexingly quick daft zebras jump. The five boxing wizards jump quickly. Pack my box with five dozen liquor jugs. Jackdaws love my big sphinx of quartz.
<p class="line-clamp-1">Truncate to one line...</p>
<p class="line-clamp-2">Truncate to two lines...</p>
<p class="line-clamp-3">Truncate to three lines...</p>
<p class="line-clamp-4">Truncate to four lines...</p>
<p class="line-clamp-5">Truncate to five lines...</p>
<p class="line-clamp-6">Truncate to six lines...</p>
| Class | Lines shown | Description |
|---|---|---|
line-clamp-1 | 1 | Single-line truncation |
line-clamp-2 | 2 | Two-line truncation |
line-clamp-3 | 3 | Three-line truncation |
line-clamp-4 | 4 | Four-line truncation |
line-clamp-5 | 5 | Five-line truncation |
line-clamp-6 | 6 | Six-line truncation |
Text ellipsis
Truncate a single line with an ellipsis. Apply .text-ellipsis together with an overflow constraint so the overflowed text is actually clipped.
<!-- Truncate long single-line labels -->
<span class="text text-ellipsis" style="white-space:nowrap; overflow:hidden; max-width:16rem; display:inline-block;">
This long label gets truncated with an ellipsis
</span>
Text Shadow
Add a soft shadow to text. .text-shadow uses the default color; .text-shadow-{color} tints the shadow with any theme color.
text-shadow - Soft shadow
text-shadow-primary - Primary glow
text-shadow-grey - Grey tint
<!-- Default soft shadow -->
<p class="text-shadow">Soft shadow</p>
<!-- Colored shadow -->
<p class="text-primary text-shadow-primary">Primary glow</p>
<!-- Pseudo-state variant -->
<p class="hover:text-shadow">Shadow on hover</p>
| Class | Properties | Description |
|---|---|---|
.text-shadow | text-shadow: 2px 2px 5px currentColor | Soft default shadow |
.text-shadow-{color} | text-shadow tinted with the theme color | Tinted shadow |
Both classes also ship hover:, focus:, and active: rivals, e.g. hover:text-shadow.
Vertical Alignment
Control the vertical alignment of inline or table-cell elements.
<span class="align-top">Top</span>
<span class="align-middle">Middle</span>
<span class="align-bottom">Bottom</span>
<span class="align-baseline">Baseline</span>
<span class="align-auto">Auto</span>
| Class | Properties | Description |
|---|---|---|
align-auto | vertical-align: auto | Browser default |
align-baseline | vertical-align: baseline | Align to text baseline |
align-top | vertical-align: top | Align to top of line box |
align-middle | vertical-align: middle | Center vertically |
align-bottom | vertical-align: bottom | Align to bottom of line box |
Responsive text
Text alignment and transform utilities both support responsive breakpoint prefixes using the mobile-first approach. Prefix any class with a breakpoint followed by :.
<!-- Left on mobile, centered from md up -->
<p class="text-left md:text-center">Responsive alignment</p>
<!-- Normal on mobile, uppercase from lg up -->
<p class="no-case lg:uppercase">Responsive transform</p>
<!-- Line clamp responsive -->
<p class="line-clamp-3 md:line-clamp-5">
More lines visible on wider screens...
</p>
Available breakpoints:xs:(375px),sm:(544px),md:(768px),lg:(992px),xl:(1200px),xxl:(1440px). See responsive docs for full details.