Text Effects

Loading concept...

✨ Text Effects in Tailwind CSS: Making Your Words Dance!


🎭 The Story of the Magic Paintbrush

Imagine you have a magic paintbrush that can decorate any word you write. You can underline words, make them fancy, stretch them tall, or even hide parts that are too long. That’s exactly what Text Effects in Tailwind CSS do!

Today, we’ll learn 6 amazing tricks with our magic paintbrush. Ready? Let’s go!


πŸ“š What We’ll Learn

  1. Text Decoration – Drawing lines under, over, or through words
  2. Text Decoration Style – Making those lines wavy, dotted, or dashed
  3. Text Decoration Thickness – Making lines thin or thick
  4. Text Transform – Changing letters to UPPERCASE, lowercase, or Capitalize
  5. Text Overflow & Truncation – Hiding extra text with β€œβ€¦β€
  6. Line Clamp – Showing only a few lines of text

1. πŸ“ Text Decoration: Drawing Lines on Words

Think of text decoration like drawing on your notebook. You can:

  • Draw a line under a word (like when you highlight important stuff)
  • Draw a line over a word (like a hat!)
  • Draw a line through a word (like crossing out mistakes)

The Magic Classes

Class What It Does
underline Draws a line under the text
overline Draws a line above the text
line-through Draws a line through the middle
no-underline Removes any line decoration

Example: Try It!

<p class="underline">
  I have a line under me!
</p>

<p class="overline">
  I have a line above me!
</p>

<p class="line-through">
  I am crossed out!
</p>

<p class="no-underline">
  I have no lines at all!
</p>

Real Life Use:

  • Links usually have underline
  • Deleted prices use line-through ($100 β†’ $50!)
  • Fancy titles might use overline

2. 🌊 Text Decoration Style: Making Lines Fun!

Now that you know how to draw lines, let’s make them stylish! Instead of boring straight lines, we can make them:

  • Solid – Regular straight line
  • Double – Two parallel lines
  • Dotted – Little dots in a row
  • Dashed – Small dashes like - - - -
  • Wavy – Squiggly like a snake! 🐍

The Magic Classes

Class What It Does
decoration-solid Normal straight line
decoration-double Two lines together
decoration-dotted Dots like . . . .
decoration-dashed Dashes like - - -
decoration-wavy Squiggly wave line

Example: Style Your Underline!

<p class="underline decoration-wavy">
  I have a wavy underline!
</p>

<p class="underline decoration-dotted">
  I have a dotted underline!
</p>

<p class="underline decoration-double">
  I have a double underline!
</p>

Pro Tip: Wavy underlines are often used to show spelling errors, just like in your word processor!


3. πŸ“ Text Decoration Thickness: Thin or Thick Lines

Some lines need to be whisper-thin. Others need to be bold and strong! You control the thickness of your decoration lines.

The Magic Classes

Class Thickness
decoration-auto Browser decides
decoration-from-font Font decides
decoration-0 No thickness
decoration-1 1 pixel thin
decoration-2 2 pixels
decoration-4 4 pixels
decoration-8 8 pixels thick!

Example: From Thin to Thick

<p class="underline decoration-1">
  Thin whisper line
</p>

<p class="underline decoration-4">
  Medium bold line
</p>

<p class="underline decoration-8">
  Super thick line!
</p>

Combine Powers! You can use style AND thickness together:

<p class="underline decoration-wavy decoration-4">
  Thick wavy underline!
</p>

4. πŸ”€ Text Transform: Changing Letter Cases

Sometimes you want to SHOUT in uppercase. Sometimes you want to whisper in lowercase. And sometimes, you want Every Word To Start With A Capital Letter.

The Magic Classes

Class What It Does
uppercase MAKES ALL LETTERS BIG
lowercase makes all letters small
capitalize Makes First Letter Big
normal-case Keeps text as you wrote it

Example: Transform Your Text!

<p class="uppercase">
  hello world
</p>
<!-- Shows: HELLO WORLD -->

<p class="lowercase">
  HELLO WORLD
</p>
<!-- Shows: hello world -->

<p class="capitalize">
  hello world
</p>
<!-- Shows: Hello World -->

Real Life Use:

  • Buttons often use uppercase
  • Names use capitalize
  • Legal text might use lowercase

5. βœ‚οΈ Text Overflow & Truncation: The Magic Scissors

What happens when text is too long for its box? It might:

  • Overflow – Spill out and look messy
  • Get clipped – Get cut off suddenly
  • Truncate – End with β€œβ€¦β€ (ellipsis)

Think of it like a box that can only fit 10 candies. If you have 15, what do you do?

The Magic Classes

Class What It Does
truncate Cuts text and adds β€œβ€¦β€
text-ellipsis Same as truncate style
text-clip Just cuts text, no β€œβ€¦β€
overflow-hidden Hides overflow content

Example: Truncate Long Text

<p class="truncate w-48">
  This is a very very very
  long sentence that won't fit!
</p>
<!-- Shows: This is a very very... -->

Important! For truncate to work, you need:

  1. A fixed width (like w-48)
  2. Single line text (it won’t work on multiple lines)

How truncate Works (Behind the Scenes)

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

6. πŸ“„ Line Clamp: Showing Only a Few Lines

What if you want to show the first 2 or 3 lines of a paragraph, then β€œβ€¦β€? That’s Line Clamp!

It’s like reading only the first page of a book to decide if you like it.

The Magic Classes

Class Lines Shown
line-clamp-1 Shows 1 line only
line-clamp-2 Shows 2 lines
line-clamp-3 Shows 3 lines
line-clamp-4 Shows 4 lines
line-clamp-5 Shows 5 lines
line-clamp-6 Shows 6 lines
line-clamp-none Shows all lines

Example: Clamp to 2 Lines

<p class="line-clamp-2">
  This is a very long paragraph
  with lots of words. It keeps
  going and going. But you will
  only see two lines of it!
</p>

Result:

This is a very long paragraph with lots of words. It keeps going and going…

Real Life Use:

  • Blog post previews (show 3 lines, then β€œRead More”)
  • Product descriptions in cards
  • News article snippets

🎨 Combining All Powers Together!

Now let’s combine everything we learned:

<h1 class="uppercase underline
           decoration-wavy
           decoration-4">
  Welcome Hero!
</h1>

<p class="line-clamp-3 capitalize">
  this is an exciting new way
  to learn tailwind css. you
  will master text effects in
  no time at all. keep going!
</p>

🧠 Quick Memory Flow

graph TD A[Text Effects] --> B[Decoration] A --> C[Transform] A --> D[Overflow] B --> B1[underline] B --> B2[overline] B --> B3[line-through] B1 --> E[Style] E --> E1[solid] E --> E2[wavy] E --> E3[dotted] B1 --> F[Thickness] F --> F1[decoration-1] F --> F2[decoration-4] F --> F3[decoration-8] C --> C1[uppercase] C --> C2[lowercase] C --> C3[capitalize] D --> D1[truncate] D --> D2[line-clamp-N]

🎯 What You Learned Today

Effect Purpose Example Class
Decoration Add lines to text underline
Style Change line look decoration-wavy
Thickness Change line width decoration-4
Transform Change letter case uppercase
Truncation Cut long text truncate
Line Clamp Limit visible lines line-clamp-3

πŸš€ You Did It!

You now have a magic paintbrush for text! You can:

βœ… Draw lines under, over, or through text βœ… Make those lines wavy, dotted, or thick βœ… Transform text to UPPERCASE or lowercase βœ… Hide extra text with β€œβ€¦β€ using truncate βœ… Show only a few lines with line-clamp

Next Step: Go play with the interactive mode and try these effects yourself!


Remember: Great design is about making text beautiful AND readable. Use these powers wisely! ✨

Loading story...

No Story Available

This concept doesn't have a story yet.

Story Preview

Story - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

Interactive Preview

Interactive - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Interactive Content

This concept doesn't have interactive content yet.

Cheatsheet Preview

Cheatsheet - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Cheatsheet Available

This concept doesn't have a cheatsheet yet.

Quiz Preview

Quiz - Premium Content

Please sign in to view this concept and start learning.

Upgrade to Premium to unlock full access to all content.

No Quiz Available

This concept doesn't have a quiz yet.