diff --git a/src/textual/widgets/_header.py b/src/textual/widgets/_header.py
index c4382906d..39f952785 100644
--- a/src/textual/widgets/_header.py
+++ b/src/textual/widgets/_header.py
@@ -25,14 +25,26 @@ class HeaderIcon(Widget):
return self.icon
-class HeaderClock(Widget):
+class HeaderClockSpace(Widget):
+ """The space taken up by the clock on the right of the header."""
+
+ DEFAULT_CSS = """
+ HeaderClockSpace {
+ dock: right;
+ width: 10;
+ padding: 0 1;
+ }
+ """
+
+ def render(self) -> str:
+ return ""
+
+
+class HeaderClock(HeaderClockSpace):
"""Display a clock on the right of the header."""
DEFAULT_CSS = """
HeaderClock {
- dock: right;
- width: 10;
- padding: 0 1;
background: $secondary-background-lighten-1;
color: $text;
text-opacity: 85%;
@@ -54,7 +66,6 @@ class HeaderTitle(Widget):
HeaderTitle {
content-align: center middle;
width: 100%;
- margin-right: 10;
}
"""
@@ -107,8 +118,7 @@ class Header(Widget):
def compose(self):
yield HeaderIcon()
yield HeaderTitle()
- if self.show_clock:
- yield HeaderClock()
+ yield HeaderClock() if self.show_clock else HeaderClockSpace()
def watch_tall(self, tall: bool) -> None:
self.set_class(tall, "-tall")
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
index 92eb75fc1..e01117b7d 100644
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -5404,132 +5404,132 @@
font-weight: 700;
}
- .terminal-1853139379-matrix {
+ .terminal-2939949418-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-1853139379-title {
+ .terminal-2939949418-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-1853139379-r1 { fill: #c5c8c6 }
- .terminal-1853139379-r2 { fill: #e8e7e5 }
- .terminal-1853139379-r3 { fill: #e1e1e1 }
+ .terminal-2939949418-r1 { fill: #c5c8c6 }
+ .terminal-2939949418-r2 { fill: #e8e7e5 }
+ .terminal-2939949418-r3 { fill: #e1e1e1 }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
- HeaderApp
+ HeaderApp
-
-
-
- ⭘HeaderApp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ ⭘HeaderApp
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+