layer style defines the layer a widget belongs to.
layer style accepts a
<name> that defines the layer this widget belongs to.
<name> must correspond to a
<name> that has been defined in a
layers style by an ancestor of this widget.
More information on layers can be found in the guide.
<name> that hasn't been defined in a
layers declaration of an ancestor of this widget has no effect.
In the example below,
#box1 is yielded before
#box1 is on the higher layer, it is drawn on top of
from textual.app import App, ComposeResult from textual.widgets import Static class LayersExample(App): CSS_PATH = "layers.css" def compose(self) -> ComposeResult: yield Static("box1 (layer = above)", id="box1") yield Static("box2 (layer = below)", id="box2") if __name__ == "__main__": app = LayersExample() app.run()
- The layout guide section on layers.
layersto define an ordered set of layers.