1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
# Text-wrap
The `text-wrap` style set how Textual should wrap text.
The default value is "wrap" which will word-wrap text.
You can also set this style to "nowrap" which will disable wrapping entirely.
## Syntax
--8<-- "docs/snippets/syntax_block_start.md"
text-wrap: wrap | nowrap;
--8<-- "docs/snippets/syntax_block_end.md"
## Example
In the following example we have two pieces of text.
The first (top) text has the default value for `text-wrap` ("wrap") which will cause text to be word wrapped as normal.
The second has `text-wrap` set to "nowrap" which disables text wrapping and results in a single line.
=== "Output"
```{.textual path="docs/examples/styles/text_wrap.py"}
```
=== "text_wrap.py"
```py
--8<-- "docs/examples/styles/text_wrap.py"
```
=== "text_wrap.tcss"
```css
--8<-- "docs/examples/styles/text_wrap.tcss"
```
## CSS
```css
text-wrap: wrap;
text-wrap: nowrap;
```
## Python
```py
widget.styles.text_wrap = "wrap"
widget.styles.text_wrap = "nowrap"
```
## See also
- [`text-overflow`](./text_overflow.md) to set what happens to text that overflows the available width.
|