Skip to content

Commit 6a248be

Browse files
committed
Fixing switch styles, adding subtle hover effect to suggest which part will move
1 parent 15b7574 commit 6a248be

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

src/textual/widgets/_switch.py

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,51 @@ class Switch(Widget, can_focus=True):
4646

4747
DEFAULT_CSS = """
4848
Switch {
49-
border: tall transparent;
50-
background: $boost;
49+
border: tall $border-blurred;
50+
background: $surface;
5151
height: auto;
5252
width: auto;
5353
padding: 0 2;
54+
&.-on > .switch--slider {
55+
color: $success;
56+
}
57+
& > .switch--slider {
58+
background: $surface-darken-1;
59+
color: $surface-lighten-2;
60+
}
61+
&:hover {
62+
border: tall $background;
63+
& > .switch--slider {
64+
color: $surface-lighten-3;
65+
}
66+
&.-on {
67+
& > .switch--slider {
68+
color: $success-lighten-1;
69+
}
70+
}
71+
}
72+
&:focus {
73+
border: tall $border;
74+
}
75+
&:light {
76+
& > .switch--slider {
77+
background: $surface-lighten-2;
78+
color: $surface-darken-1;
79+
}
80+
&.-on {
81+
& > .switch--slider {
82+
color: $success-lighten-1;
83+
}
84+
&:hover > .switch--slider {
85+
color: $success;
86+
}
87+
}
88+
&:hover > .switch--slider {
89+
color: $surface-darken-2;
90+
}
91+
}
5492
}
5593
56-
Switch > .switch--slider {
57-
background: $panel-darken-2;
58-
color: $panel-lighten-2;
59-
}
60-
61-
Switch:hover {
62-
border: tall $background;
63-
}
64-
65-
Switch:focus {
66-
border: tall $accent;
67-
}
68-
69-
Switch.-on {
70-
71-
}
72-
73-
Switch.-on > .switch--slider {
74-
color: $success;
75-
}
7694
"""
7795

7896
value: reactive[bool] = reactive(False, init=False)

src/textual/widgets/_tree.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,19 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
619619
}
620620
}
621621
622+
&:light {
623+
/* In light mode the guides are darker*/
624+
& > .tree--guides {
625+
color: $surface-darken-1;
626+
}
627+
& > .tree--guides-hover {
628+
color: $surface-darken-2;
629+
}
630+
& > .tree--guides-selected {
631+
color: $surface-darken-2;
632+
}
633+
}
634+
622635
&.-ansi {
623636
background: ansi_default;
624637
color: ansi_default;

0 commit comments

Comments
 (0)