UNPKG

1.35 kBMarkdownView Raw
1The friendly-wrap component lets you wrap text in a predictable way by appending [`<wbr>`] elements
2to specific break-symbols.
3
4[`<wbr>`]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr
5
6## Internet Explorer 11
7
8IE11 doesn't support the `<wbr>` element: <https://caniuse.com/#search=wbr>
9To use this component on IE11, you'll need some CSS to preserve its behaviour:
10
11```css
12wbr {
13 display: inline-block;
14}
15```
16
17## Usage
18
19### Default
20
21By default, `GlFriendlyWrap` wraps text with slashes (`/`) as the break-symbol, which is especially
22useful when displaying paths or URLs:
23
24```html
25<gl-friendly-wrap text="/some/file/path" />
26```
27
28The code above renders to the following HTML:
29
30```html
31<span class="text-break">/<wbr>some/<wbr>file/<wbr>path</span>
32```
33
34### Custom symbols
35
36Multiple custom break-symbols can be defined via the `GlFriendlyWrap` prop:
37
38```html
39<gl-friendly-wrap
40 :symbols="[';', '-', '.']"
41 text="some;text-that.needs;to-be.wrapped"
42/>
43```
44
45Which renders to:
46
47```html
48<span class="text-break">some;<wbr>text-<wbr>that.<wbr>needs;<wbr>to-<wbr>be.<wbr>wrapped</span>
49```
50
51### Break words
52
53Symbols can be words too:
54
55```html
56<gl-friendly-wrap
57 :symbols="['and']"
58 text="it goes on and on and on and on"
59/>
60```
61
62Which renders to:
63
64```html
65<span class="text-break">it goes on and<wbr> on and<wbr> on and<wbr> on</span>
66```