Link the Header docs to App.title and App.sub_title

Closes #3103.
This commit is contained in:
Dave Pearson
2023-08-21 12:57:16 +01:00
parent 39473fc17c
commit 30bd82e25e
2 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
from textual.app import App, ComposeResult
from textual.widgets import Header
class HeaderApp(App):
def compose(self) -> ComposeResult:
yield Header()
def on_mount(self) -> None:
self.title = "Header Application"
self.sub_title = "With title and sub-title"
if __name__ == "__main__":
app = HeaderApp()
app.run()

View File

@@ -2,6 +2,10 @@
A simple header widget which docks itself to the top of the parent container.
!!! note
The application title which is shown in the header is taken from the [`title`][textual.app.App.title] and [`sub_title`][textual.app.App.sub_title] of the application.
- [ ] Focusable
- [ ] Container
@@ -20,6 +24,19 @@ The example below shows an app with a `Header`.
--8<-- "docs/examples/widgets/header.py"
```
This example shows how to set the text in the `Header` using `App.title` and `App.sub_title`:
=== "Output"
```{.textual path="docs/examples/widgets/header_app_title.py"}
```
=== "header_app_title.py"
```python
--8<-- "docs/examples/widgets/header_app_title.py"
```
## Reactive Attributes
| Name | Type | Default | Description |