Skip to content

Commit 4f184c6

Browse files
avelinelaurkim
andauthored
Add breakWord prop to Text (#7389)
### WHAT is this pull request doing? Add `breakWord` prop to `Text` to support functionality offered by the [`text-breakword` mixin](https://github.com/Shopify/polaris/blob/main/polaris-react/src/styles/shared/_typography.scss#L143) Co-authored-by: Lo Kim <[email protected]>
1 parent 87981ac commit 4f184c6

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

.changeset/pink-forks-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Added `breakWord` prop to `Text`

polaris-react/src/components/Text/Text.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,7 @@
121121
font-size: var(--p-font-size-200);
122122
line-height: var(--p-font-line-height-2);
123123
}
124+
125+
.break {
126+
overflow-wrap: break-word;
127+
}

polaris-react/src/components/Text/Text.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export interface TextProps {
5353
alignment?: Alignment;
5454
/** The element type */
5555
as: Element;
56+
/** Prevent text from overflowing */
57+
breakWord?: boolean;
5658
/** Text to display */
5759
children: ReactNode;
5860
/** Adjust color of text */
@@ -72,6 +74,7 @@ export interface TextProps {
7274
export const Text = ({
7375
alignment,
7476
as,
77+
breakWord,
7578
children,
7679
color,
7780
fontWeight,
@@ -88,6 +91,7 @@ export const Text = ({
8891
fontWeight ? styles[fontWeight] : styles[VariantFontWeightMapping[variant]],
8992
(alignment || truncate) && styles.block,
9093
alignment && styles[alignment],
94+
breakWord && styles.break,
9195
color && styles[color],
9296
truncate && styles.truncate,
9397
visuallyHidden && styles.visuallyHidden,

0 commit comments

Comments
 (0)