diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8839e0f25..6726edc577 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- "Discover" hits in the command palette are no longer sorted alphabetically https://github.com/Textualize/textual/pull/4720
- `Markdown.LinkClicked.href` is now automatically unquoted https://github.com/Textualize/textual/pull/4749
+### Added
+
+- Added `Footer` component style handling of padding for the key/description https://github.com/Textualize/textual/pull/4651
+
## [0.72.0] - 2024-07-09
### Changed
@@ -55,7 +59,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed link inside markdown table not posting a `Markdown.LinkClicked` message https://github.com/Textualize/textual/issues/4683
- Fixed issue with mouse movements on non-active screen https://github.com/Textualize/textual/pull/4688
-
## [0.70.0] - 2024-06-19
### Fixed
diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py
index aa39e3719e..09a743ac48 100644
--- a/src/textual/widgets/_footer.py
+++ b/src/textual/widgets/_footer.py
@@ -33,6 +33,11 @@ class FooterKey(Widget):
color: $secondary;
background: $panel;
text-style: bold;
+ padding: 0 1;
+ }
+
+ .footer-key--description {
+ padding: 0 1 0 0;
}
&:light .footer-key--key {
@@ -57,6 +62,14 @@ class FooterKey(Widget):
}
}
+ &.-compact {
+ .footer-key--key {
+ padding: 0;
+ }
+ .footer-key--description {
+ padding: 0 0 0 1;
+ }
+ }
}
"""
@@ -83,19 +96,27 @@ def render(self) -> Text:
key_style = self.get_component_rich_style("footer-key--key")
description_style = self.get_component_rich_style("footer-key--description")
key_display = self.key_display
+ key_padding = self.get_component_styles("footer-key--key").padding
+ description_padding = self.get_component_styles(
+ "footer-key--description"
+ ).padding
if self.upper_case_keys:
key_display = key_display.upper()
if self.ctrl_to_caret and key_display.lower().startswith("ctrl+"):
key_display = "^" + key_display.split("+", 1)[1]
description = self.description
- if self.compact:
- label_text = Text.assemble(
- (key_display, key_style), " ", (description, description_style)
- )
- else:
- label_text = Text.assemble(
- (f" {key_display} ", key_style), (description, description_style), " "
- )
+ label_text = Text.assemble(
+ (
+ " " * key_padding.left + key_display + " " * key_padding.right,
+ key_style,
+ ),
+ (
+ " " * description_padding.left
+ + description
+ + " " * description_padding.right,
+ description_style,
+ ),
+ )
label_text.stylize_before(self.rich_style)
return label_text
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
index fc13eb3a6d..5efd95785d 100644
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -21310,6 +21310,480 @@
'''
# ---
+# name: test_footer_classic_styling
+ '''
+
+
+ '''
+# ---
+# name: test_footer_compact
+ '''
+
+
+ '''
+# ---
+# name: test_footer_compact_with_hover
+ '''
+
+
+ '''
+# ---
# name: test_footer_render
'''