Stripped personal data from development repository
Samo Penic
2019-02-20 83c3f647c35477564b77cbc5b36d37d793d5442a
commit | author | age
83c3f6 1 ---
SP 2 layout: docs
3 title: Text
4 description: Documentation and examples for common text utilities to control alignment, wrapping, weight, and more.
5 group: utilities
6 toc: true
7 ---
8
9 ## Text alignment
10
11 Easily realign text to components with text alignment classes.
12
13 {% capture example %}
14 <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>
15 {% endcapture %}
16 {% include example.html content=example %}
17
18 For left, right, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.
19
20 {% capture example %}
21 <p class="text-left">Left aligned text on all viewport sizes.</p>
22 <p class="text-center">Center aligned text on all viewport sizes.</p>
23 <p class="text-right">Right aligned text on all viewport sizes.</p>
24
25 <p class="text-sm-left">Left aligned text on viewports sized SM (small) or wider.</p>
26 <p class="text-md-left">Left aligned text on viewports sized MD (medium) or wider.</p>
27 <p class="text-lg-left">Left aligned text on viewports sized LG (large) or wider.</p>
28 <p class="text-xl-left">Left aligned text on viewports sized XL (extra-large) or wider.</p>
29 {% endcapture %}
30 {% include example.html content=example %}
31
32 ## Text wrapping and overflow
33
34 Wrap text with a `.text-wrap` class.
35
36 {% capture example %}
37 <div class="badge badge-primary text-wrap" style="width: 6rem;">
38   This text should wrap.
39 </div>
40 {% endcapture %}
41 {% include example.html content=example %}
42
43 Prevent text from wrapping with a `.text-nowrap` class.
44
45 {% capture example %}
46 <div class="text-nowrap bd-highlight" style="width: 8rem;">
47   This text should overflow the parent.
48 </div>
49 {% endcapture %}
50 {% include example.html content=example %}
51
52 For longer content, you can add a `.text-truncate` class to truncate the text with an ellipsis. **Requires `display: inline-block` or `display: block`.**
53
54 {% capture example %}
55 <!-- Block level -->
56 <div class="row">
57   <div class="col-2 text-truncate">
58     Praeterea iter est quasdam res quas ex communi.
59   </div>
60 </div>
61
62 <!-- Inline level -->
63 <span class="d-inline-block text-truncate" style="max-width: 150px;">
64   Praeterea iter est quasdam res quas ex communi.
65 </span>
66 {% endcapture %}
67 {% include example.html content=example %}
68
69 ## Text transform
70
71 Transform text in components with text capitalization classes.
72
73 {% capture example %}
74 <p class="text-lowercase">Lowercased text.</p>
75 <p class="text-uppercase">Uppercased text.</p>
76 <p class="text-capitalize">CapiTaliZed text.</p>
77 {% endcapture %}
78 {% include example.html content=example %}
79
80 Note how `.text-capitalize` only changes the first letter of each word, leaving the case of any other letters unaffected.
81
82 ## Font weight and italics
83
84 Quickly change the weight (boldness) of text or italicize text.
85
86 {% capture example %}
87 <p class="font-weight-bold">Bold text.</p>
88 <p class="font-weight-bolder">Bolder weight text (relative to the parent element).</p>
89 <p class="font-weight-normal">Normal weight text.</p>
90 <p class="font-weight-light">Light weight text.</p>
91 <p class="font-weight-lighter">Lighter weight text (relative to the parent element).</p>
92 <p class="font-italic">Italic text.</p>
93 {% endcapture %}
94 {% include example.html content=example %}
95
96 ## Monospace
97
98 Change a selection to our monospace font stack with `.text-monospace`.
99
100 {% capture example %}
101 <p class="text-monospace">This is in monospace</p>
102 {% endcapture %}
103 {% include example.html content=example %}
104
105 ## Reset color
106
107 Reset a text or link's color with `.text-reset`, so that it inherits the color from its parent.
108
109 {% capture example %}
110 <p class="text-muted">
111   Muted text with a <a href="#" class="text-reset">reset link</a>.
112 </p>
113 {% endcapture %}
114 {% include example.html content=example %}
115
116 ## Text decoration
117
118 Remove a text decoration with a `.text-decoration-none` class.
119
120 {% capture example %}
121 <a href="#" class="text-decoration-none">Non-underlined link</a>
122 {% endcapture %}
123 {% include example.html content=example %}