Add some default styling to the toggle button classes

This won't be the final form, I feel this is a good point to start to think
about making standard styles for this sort of thing in Textual, but this
here helps me see what's going on.
This commit is contained in:
Dave Pearson
2023-02-16 10:53:56 +00:00
parent c114c872f2
commit 9dea934feb

View File

@@ -15,7 +15,7 @@ from ..reactive import reactive
from ._static import Static
class ToggleButton(Static):
class ToggleButton(Static, can_focus=True):
"""Base toggle button widget."""
BINDINGS: ClassVar[list[BindingType]] = [
@@ -27,6 +27,18 @@ class ToggleButton(Static):
| enter,space | Toggle the value. |
"""
DEFAULT_CSS = """
ToggleButton:hover {
text-style: bold;
background: $boost;
}
ToggleButton:focus {
color: $text;
background: $secondary;
}
""" # TODO: https://github.com/Textualize/textual/issues/1780
button_prefix: reactive[TextType] = reactive[TextType]("[")
"""The character for the left side of the toggle button."""