Save time with Textual containers¶
Textual's containers provide a convenient way of arranging your widgets. Let's look at them in a little detail.
Are you in the right place?
We are talking about Textual container widgets here. Not to be confused with containerization—which is something else entirely!
What are containers?¶
Containers are reusable compound widgets with preset styles to arrange their children. For instance, there is a Horizontal container which arranges all of its children in a horizontal row. Let's look at a quick example of that:
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Placeholder
class Box(Placeholder):
"""Example widget."""
DEFAULT_CSS = """
Box {
width: 16;
height: 8;
}
"""
class ContainerApp(App):
"""Simple app to play with containers."""
def compose(self) -> ComposeResult:
with Horizontal(): # (1)!
yield Box() # (2)!