fix styles examples, box model docs

This commit is contained in:
Will McGugan
2022-09-10 16:45:13 +01:00
parent 39c6dee84f
commit 269960ad8a
8 changed files with 37 additions and 8 deletions

View File

@@ -7,7 +7,18 @@ Textual provides a large number of *styles* you can use to customize how your ap
Every widget class in Textual provides a `styles` object which contains a number of writable attributes. Styles define the position and size of a widget, in addition to color, text style, borders, alignment and much more.
Let's look at a simple example which sets the styles on the `screen` (a special widget that represents the screen).
```python title="screen.py" hl_lines="6-7"
--8<-- "docs/examples/guide/styles/screen.py"
```
The first line sets `screen.styles.background` to `"darkblue"` which will change the background color to dark blue. There are a few other ways of setting color which we will explore later.
The second line sets `screen.styles.border` to a tuple of `("heavy", "white")` which tells Textual to draw a white border with a style of `"heavy"`. Running this code will show the following:
```{.textual path="docs/examples/guide/styles/screen.py"}
```
## Box Model