2016-09-09 06:48:17 +02:00
---
layout: docs
2017-08-17 10:19:44 +02:00
title: Text
2017-05-28 20:25:59 +02:00
description: Documentation and examples for common text utilities to control alignment, wrapping, weight, and more.
2016-09-09 06:48:17 +02:00
group: utilities
2017-05-28 20:25:59 +02:00
toc: true
2016-09-09 06:48:17 +02:00
---
## Text alignment
Easily realign text to components with text alignment classes.
2018-03-14 16:44:38 +01:00
{% capture example %}
2016-09-09 06:48:17 +02:00
< p class = "text-justify" > Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae in diem certam indicere. Cras mattis iudicium purus sit amet fermentum.< / p >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-09-09 06:48:17 +02:00
For left, right, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.
2018-03-14 16:44:38 +01:00
{% capture example %}
2016-11-27 05:33:46 +01:00
< p class = "text-left" > Left aligned text on all viewport sizes.< / p >
< p class = "text-center" > Center aligned text on all viewport sizes.< / p >
< p class = "text-right" > Right aligned text on all viewport sizes.< / p >
2016-09-09 06:48:17 +02:00
< p class = "text-sm-left" > Left aligned text on viewports sized SM (small) or wider.< / p >
< p class = "text-md-left" > Left aligned text on viewports sized MD (medium) or wider.< / p >
< p class = "text-lg-left" > Left aligned text on viewports sized LG (large) or wider.< / p >
< p class = "text-xl-left" > Left aligned text on viewports sized XL (extra-large) or wider.< / p >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-09-09 06:48:17 +02:00
2017-03-09 20:36:32 +01:00
## Text wrapping and overflow
Prevent text from wrapping with a `.text-nowrap` class.
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-12-23 01:49:57 +01:00
< div class = "text-nowrap bd-highlight" style = "width: 8rem;" >
This text should overflow the parent.
2017-03-09 20:36:32 +01:00
< / div >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2017-03-09 20:36:32 +01:00
2017-07-02 05:27:15 +02:00
For longer content, you can add a `.text-truncate` class to truncate the text with an ellipsis. **Requires `display: inline-block` or `display: block`.**
2017-03-09 20:36:32 +01:00
2018-03-14 16:44:38 +01:00
{% capture example %}
2017-07-02 05:27:15 +02:00
<!-- Block level -->
2017-03-09 20:36:32 +01:00
< div class = "row" >
< div class = "col-2 text-truncate" >
Praeterea iter est quasdam res quas ex communi.
< / div >
< / div >
2017-07-02 05:27:15 +02:00
<!-- Inline level -->
< span class = "d-inline-block text-truncate" style = "max-width: 150px;" >
Praeterea iter est quasdam res quas ex communi.
< / span >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2017-03-09 20:36:32 +01:00
2016-09-09 06:48:17 +02:00
## Text transform
Transform text in components with text capitalization classes.
2018-03-14 16:44:38 +01:00
{% capture example %}
2016-09-09 06:48:17 +02:00
< p class = "text-lowercase" > Lowercased text.< / p >
< p class = "text-uppercase" > Uppercased text.< / p >
< p class = "text-capitalize" > CapiTaliZed text.< / p >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2016-09-09 06:48:17 +02:00
Note how `text-capitalize` only changes the first letter of each word, leaving the case of any other letters unaffected.
## Font weight and italics
Quickly change the weight (boldness) of text or italicize text.
2018-03-14 16:44:38 +01:00
{% capture example %}
2016-09-09 06:48:17 +02:00
< p class = "font-weight-bold" > Bold text.< / p >
< p class = "font-weight-normal" > Normal weight text.< / p >
2017-09-17 08:53:05 +02:00
< p class = "font-weight-light" > Light weight text.< / p >
2016-09-09 06:48:17 +02:00
< p class = "font-italic" > Italic text.< / p >
2018-03-14 16:44:38 +01:00
{% endcapture %}
{% include example.html content=example %}
2018-04-01 06:04:54 +02:00
## Monospace
Change a selection to our monospace font stack with `.text-monospace` .
{% capture example %}
< p class = "font-monospace" > This is in monospace< / p >
{% endcapture %}
{% include example.html content=example %}