Files
textual/docs/styles/layers.md
2023-12-20 17:11:30 +00:00

1.6 KiB

Layers

The layers style allows you to define an ordered set of layers.

Syntax

--8<-- "docs/snippets/syntax_block_start.md" layers: <name>+; --8<-- "docs/snippets/syntax_block_end.md"

The layers style accepts one or more <name> that define the layers that the widget is aware of, and the order in which they will be painted on the screen.

The values used here can later be referenced using the layer property. The layers defined first in the list are drawn under the layers that are defined later in the list.

More information on layers can be found in the guide.

Example

In the example below, #box1 is yielded before #box2. However, since #box1 is on the higher layer, it is drawn on top of #box2.

=== "Output"

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

=== "layers.py"

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

=== "layers.tcss"

```css hl_lines="3 14 19"
--8<-- "docs/examples/guide/layout/layers.tcss"
```

CSS

/* Bottom layer is called 'below', layer above it is called 'above' */
layers: below above;

Python

# Bottom layer is called 'below', layer above it is called 'above'
widget.style.layers = ("below", "above")

See also