File: layout.md

package info (click to toggle)
textual 2.1.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,080 kB
  • sloc: python: 85,423; lisp: 1,669; makefile: 101
file content (60 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (2)
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
# Layout

The `layout` style defines how a widget arranges its children.

## Syntax

--8<-- "docs/snippets/syntax_block_start.md"
layout: grid | horizontal | vertical;
--8<-- "docs/snippets/syntax_block_end.md"

The `layout` style takes an option that defines how child widgets will be arranged, as per the table shown below.

### Values

| Value                | Description                                                                   |
| -------------------- | ----------------------------------------------------------------------------- |
| `grid`               | Child widgets will be arranged in a grid.                                     |
| `horizontal`         | Child widgets will be arranged along the horizontal axis, from left to right. |
| `vertical` (default) | Child widgets will be arranged along the vertical axis, from top to bottom.   |

See the [layout](../guide/layout.md) guide for more information.

## Example

Note how the `layout` style affects the arrangement of widgets in the example below.
To learn more about the grid layout, you can see the [layout guide](../guide/layout.md) or the [grid reference](./grid/index.md).

=== "Output"

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

=== "layout.py"

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

=== "layout.tcss"

    ```css hl_lines="2 8"
    --8<-- "docs/examples/styles/layout.tcss"
    ```

## CSS

```css
layout: horizontal;
```

## Python

```python
widget.styles.layout = "horizontal"
```

## See also

 - [Layout guide](../guide/layout.md).
 - [Grid reference](./grid/index.md).