Skip to content

Commit 4d2386b

Browse files
committed
expose icon
1 parent 14f5a9d commit 4d2386b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515
- Buttons may not be pressed within their "active_effect_duration" to prevent inadvertent activations https://github.com/Textualize/textual/pull/4621
1616
- `Screen.dismiss` is now a noop if the screen isn't active. Previously it would raise a `ScreenStackError`, now it returns `False`. https://github.com/Textualize/textual/pull/4621
1717
- Increased window for escape processing to 100ms
18+
- Added `icon` reactive to Header widget
1819

1920
### Added
2021

src/textual/widgets/_header.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,17 @@ class Header(Widget):
139139
tall: Reactive[bool] = Reactive(False)
140140
"""Set to `True` for a taller header or `False` for a single line header."""
141141

142+
icon: Reactive[str] = Reactive("⭘")
143+
"""A character for the icon at the top left."""
144+
142145
def __init__(
143146
self,
144147
show_clock: bool = False,
145148
*,
146149
name: str | None = None,
147150
id: str | None = None,
148151
classes: str | None = None,
152+
icon: str | None = None,
149153
):
150154
"""Initialise the header widget.
151155
@@ -157,9 +161,11 @@ def __init__(
157161
"""
158162
super().__init__(name=name, id=id, classes=classes)
159163
self._show_clock = show_clock
164+
if icon is not None:
165+
self.icon = icon
160166

161167
def compose(self):
162-
yield HeaderIcon()
168+
yield HeaderIcon().data_bind(Header.icon)
163169
yield HeaderTitle()
164170
yield HeaderClock() if self._show_clock else HeaderClockSpace()
165171

0 commit comments

Comments
 (0)