Skip to content

Commit 68b3602

Browse files
committed
Replace white-space utilities with text-wrap utilities, add new ones
1 parent e5a1ee3 commit 68b3602

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

scss/_utilities.scss

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,20 +624,22 @@ $utilities: map.merge(
624624
class: text,
625625
values: lowercase uppercase capitalize
626626
),
627-
"white-space": (
628-
property: white-space,
629-
class: text,
630-
values: (
631-
wrap: normal,
632-
nowrap: nowrap,
633-
)
634-
),
635627
"word-wrap": (
636628
property: word-wrap word-break,
637629
class: text,
638630
values: (break: break-word),
639631
rtl: false
640632
),
633+
"text-wrap": (
634+
property: text-wrap,
635+
class: text,
636+
values: (
637+
balance: balance,
638+
nowrap: nowrap,
639+
pretty: pretty,
640+
wrap: wrap,
641+
)
642+
),
641643
// scss-docs-end utils-text
642644
// scss-docs-start utils-color
643645
"color-attr": (

site/src/content/docs/utilities/text.mdx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ Easily realign text to components with text alignment classes. For start, end, a
120120
Note that we don’t provide utility classes for justified text. While, aesthetically, justified text might look more appealing, it does make word-spacing more random and therefore harder to read.
121121
</Callout>
122122

123-
## Text wrapping and overflow
123+
## Text wrap
124124

125125
Wrap text with a `.text-wrap` class.
126126

127-
<Example code={`<div class="badge text-bg-primary text-wrap" style="width: 6rem;">
128-
This text should wrap.
127+
<Example code={`<div class="text-wrap bg-body-secondary border" style="width: 8rem;">
128+
This snippet of text should wrap.
129129
</div>`} />
130130

131131
Prevent text from wrapping with a `.text-nowrap` class.
@@ -134,6 +134,18 @@ Prevent text from wrapping with a `.text-nowrap` class.
134134
This text should overflow the parent.
135135
</div>`} />
136136

137+
Use `.text-balance` to balance evenly distribute text across multiple lines. This is computationally expensive and is thus limited by the Chromium to six lines and by Firefox to ten lines.
138+
139+
<Example code={`<div class="text-balance mx-auto" style="width: 20rem;">
140+
This text should be balanced. Here we’re writing a longer snippet of text to form a paragraph and demonstrate how the text wraps.
141+
</div>`} />
142+
143+
Use `.text-pretty` to prevent single words their own line (orphans). **Pretty text wrapping is not fully supported in Safari and Firefox at the moment.**
144+
145+
<Example code={`<div class="text-pretty mx-auto" style="width: 20rem;">
146+
This text should be pretty. Here we’re writing a longer snippet of text to form a paragraph and demonstrate how the text wraps.
147+
</div>`} />
148+
137149
## Word break
138150

139151
Prevent long strings of text from breaking your components’ layout by using `.text-break` to set `word-wrap: break-word` and `word-break: break-word`. We use `word-wrap` instead of the more common `overflow-wrap` for wider browser support, and add the deprecated `word-break: break-word` to avoid issues with flex containers.

0 commit comments

Comments
 (0)