Skip to content

Commit 30bd82e

Browse files
committed
Link the Header docs to App.title and App.sub_title
Closes #3103.
1 parent 39473fc commit 30bd82e

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from textual.app import App, ComposeResult
2+
from textual.widgets import Header
3+
4+
5+
class HeaderApp(App):
6+
def compose(self) -> ComposeResult:
7+
yield Header()
8+
9+
def on_mount(self) -> None:
10+
self.title = "Header Application"
11+
self.sub_title = "With title and sub-title"
12+
13+
14+
if __name__ == "__main__":
15+
app = HeaderApp()
16+
app.run()

docs/widgets/header.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
A simple header widget which docks itself to the top of the parent container.
44

5+
!!! note
6+
7+
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.
8+
59
- [ ] Focusable
610
- [ ] Container
711

@@ -20,6 +24,19 @@ The example below shows an app with a `Header`.
2024
--8<-- "docs/examples/widgets/header.py"
2125
```
2226

27+
This example shows how to set the text in the `Header` using `App.title` and `App.sub_title`:
28+
29+
=== "Output"
30+
31+
```{.textual path="docs/examples/widgets/header_app_title.py"}
32+
```
33+
34+
=== "header_app_title.py"
35+
36+
```python
37+
--8<-- "docs/examples/widgets/header_app_title.py"
38+
```
39+
2340
## Reactive Attributes
2441

2542
| Name | Type | Default | Description |

0 commit comments

Comments
 (0)