Bootstrap 5 – Utility API
Estimated reading: 4 minutes 14 views

📝 Bootstrap 5 – Text Utilities: Alignment, Wrapping, Sizing & More

🧲 Introduction – Why Use Text Utilities in Bootstrap 5?

Bootstrap 5 offers a full suite of text utility classes that help you style, align, transform, wrap, truncate, and size your text without needing custom CSS. These utilities enable fast development of clean, consistent typography across different devices and screen sizes.

🎯 In this guide, you’ll learn:

  • How to align and transform text responsively
  • Use text wrapping, truncation, and reset utilities
  • Control text sizes and weight with Bootstrap classes
  • Apply responsive text behaviors for real-world components

✅ Example 1 – Text Alignment Utilities

<p class="text-start">Aligned left (start)</p>
<p class="text-center">Aligned center</p>
<p class="text-end">Aligned right (end)</p>
ClassDescription
text-startAligns text to the left (LTR)
text-centerAligns text to the center
text-endAligns text to the right (LTR)

📱 Add responsive suffixes like text-md-end for alignment on specific breakpoints.


✅ Example 2 – Text Wrapping & Truncation

<div class="text-nowrap bg-light border p-2">This text will not wrap to the next line</div>
<div class="text-truncate" style="width: 150px;">
  This long text will be truncated with ellipsis
</div>
ClassDescription
text-nowrapPrevents wrapping (text stays in one line)
text-truncateTruncates text with ... if it overflows width

⚠️ text-truncate works only with overflow: hidden; and a fixed width container.


✅ Example 3 – Text Transformation Utilities

<p class="text-lowercase">LOWERCASE TEXT</p>
<p class="text-uppercase">uppercase text</p>
<p class="text-capitalize">capitalize every word</p>
ClassDescription
text-lowercaseConverts all letters to lowercase
text-uppercaseConverts all letters to uppercase
text-capitalizeCapitalizes the first letter of each word

📌 Great for headings, navigation labels, or titles.


✅ Example 4 – Font Weight and Italics

<p class="fw-bold">Bold font weight</p>
<p class="fw-light">Light font weight</p>
<p class="fst-italic">Italic text style</p>
ClassEffect
fw-boldMakes text bold
fw-lightApplies light weight
fst-italicItalicizes text

🧱 You can combine them for stylized emphasis: fw-bold fst-italic.


✅ Example 5 – Responsive Text Sizing

<p class="fs-1">Font size 1 (largest)</p>
<p class="fs-3">Font size 3</p>
<p class="fs-6">Font size 6 (smallest)</p>
ClassFont Size Purpose
fs-1Largest heading-sized text
fs-6Smallest readable text

🎯 Ideal for dashboards, headers, footers, cards, and buttons.


📘 Text Utility Class Reference

Utility GroupCommon Classes
Alignmenttext-start, text-center, text-end
Wrappingtext-wrap, text-nowrap, text-break
Truncationtext-truncate
Transformationtext-uppercase, text-lowercase, text-capitalize
Font Stylefst-italic, fst-normal
Font Weightfw-light, fw-normal, fw-bold
Font Sizefs-1 to fs-6

✅ All utilities support responsive suffixes (e.g., text-md-center, fs-lg-3).


🛠️ Best Practices for Text Utilities

Best PracticeWhy It Matters
Use semantic class namesKeeps typography consistent and accessible
Combine text utilities with spacingAligns and positions content clearly
Truncate only when necessaryAvoids UX confusion; provide full text on hover
Test across screen sizesEnsure readability and layout responsiveness
Use responsive text alignmentHelps align text differently for mobile vs desktop

📌 Summary – Recap & Next Steps

Bootstrap 5 text utilities allow for fast, flexible, and consistent typography control across your UI. From alignment to truncation, transformation, and responsive sizing, you can build well-structured and readable layouts with just classes.

🔍 Key Takeaways:

  • Use text-start, text-end, text-center for alignment
  • Apply text-uppercase, text-lowercase, text-capitalize for transformation
  • Utilize fw-* and fs-* for font weight and size
  • text-truncate and text-nowrap are handy for limited-width layouts
  • Combine with spacing and color classes for full visual control

⚙️ Best for landing pages, dashboards, cards, headers, navbars, and forms.


❓ FAQs – Bootstrap 5 Text Utilities

What’s the difference between text-wrap and text-nowrap?
text-wrap allows text to break and flow normally. text-nowrap forces text to stay in a single line, potentially overflowing if no truncation is set.


How do I use text utilities responsively?
✅ Add breakpoint suffixes like text-md-center or fs-lg-4 to change text alignment or size based on device width.


Can I combine font size and weight utilities?
✅ Yes. For example, use fs-3 fw-bold for a medium-bold heading.


Is text-truncate accessible?
✅ Only partially. Consider adding tooltips or ARIA labels to show full content if the text is truncated.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

Bootstrap 5 – Text Utilities

Or Copy Link

CONTENTS
Scroll to Top