File size: 1,129 Bytes
5b76e0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Text-align

The `text-align` rule aligns text within a widget.

## Syntax

```
text-align: [left|start|center|right|end|justify];
```

### Values

| Value     | Description                      |
|-----------|----------------------------------|
| `left`    | Left aligns text in the widget   |
| `start`   | Left aligns text in the widget   |
| `center`  | Center aligns text in the widget |
| `right`   | Right aligns text in the widget  |
| `end`     | Right aligns text in the widget  |
| `justify` | Justifies text in the widget     |

## Example

This example shows, from top to bottom: `left`, `center`, `right`, and `justify` text alignments.

=== "text_align.py"

    ```python
    --8<-- "docs/examples/styles/text_align.py"
    ```

=== "text_align.css"

    ```css
    --8<-- "docs/examples/styles/text_align.css"
    ```

=== "Output"

    ```{.textual path="docs/examples/styles/text_align.py"}
    ```

## CSS

```sass
/* Set text in all Widgets to be right aligned */
Widget {
    text-align: right;
}
```

## Python

```python
# Set text in the widget to be right aligned
widget.styles.text_align = "right"
```