Skip to content

Commit 9af59d6

Browse files
committed
CSS tweaks
1 parent c096a3f commit 9af59d6

File tree

8 files changed

+49
-45
lines changed

8 files changed

+49
-45
lines changed

src/textual/widgets/_data_table.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,14 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
320320
height: auto;
321321
max-height: 100%;
322322
323+
&:focus {
324+
background-tint: $foreground 5%;
325+
& > .datatable--cursor {
326+
background: $highlight-cursor;
327+
color: $text;
328+
}
329+
}
330+
323331
&:dark {
324332
background: $surface;
325333
& > .datatable--even-row {
@@ -351,11 +359,6 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
351359
color: $text;
352360
}
353361
354-
&:focus > .datatable--cursor {
355-
background: $highlight-cursor;
356-
color: $text;
357-
}
358-
359362
& > .datatable--fixed-cursor {
360363
background: $highlight-cursor 92%;
361364
color: $text;

src/textual/widgets/_input.py

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class Input(Widget, can_focus=True):
155155
156156
&:focus {
157157
border: tall $border;
158+
background-tint: $foreground 5%;
158159
}
159160
&>.input--cursor {
160161
background: $surface;

src/textual/widgets/_list_view.py

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
3131
& > ListItem.--highlight {
3232
background: $highlight-cursor-blurred;
3333
}
34+
&:focus-within {
35+
background-tint: $foreground 5%;
36+
}
3437
&:focus > ListItem.--highlight {
3538
background: $highlight-cursor;
3639
}

src/textual/widgets/_option_list.py

+29-34
Original file line numberDiff line numberDiff line change
@@ -144,41 +144,36 @@ class OptionList(ScrollView, can_focus=True):
144144
border: tall transparent;
145145
padding: 0 1;
146146
background: $surface;
147-
}
148-
149-
OptionList:focus {
150-
border: tall $border;
151-
}
152-
153-
OptionList > .option-list--separator {
154-
color: $foreground 15%;
155-
}
156-
157-
OptionList > .option-list--option-highlighted {
158-
color: $text;
159-
background: $highlight-cursor-blurred;
160-
}
161-
162-
OptionList:focus > .option-list--option-highlighted {
163-
background: $highlight-cursor;
164-
}
165-
166-
OptionList > .option-list--option-disabled {
167-
color: $text-disabled;
168-
}
169-
170-
OptionList > .option-list--option-hover {
171-
background: $highlight-hover;
172-
}
173-
174-
OptionList > .option-list--option-hover-highlighted {
175-
background: $accent 60%;
176-
color: $text;
177-
}
147+
148+
&:focus {
149+
border: tall $border;
150+
background-tint: $foreground 5%;
151+
& > .option-list--option-highlighted {
152+
background: $highlight-cursor;
153+
}
154+
}
178155
179-
OptionList:focus > .option-list--option-hover-highlighted {
180-
background: $accent;
181-
color: $text;
156+
& > .option-list--option-hover-highlighted {
157+
background: $accent;
158+
color: $text;
159+
}
160+
& > .option-list--separator {
161+
color: $foreground 15%;
162+
}
163+
& > .option-list--option-highlighted {
164+
color: $text;
165+
background: $highlight-cursor-blurred;
166+
}
167+
& > .option-list--option-disabled {
168+
color: $text-disabled;
169+
}
170+
& > .option-list--option-hover {
171+
background: $highlight-hover;
172+
}
173+
& > .option-list--option-hover-highlighted {
174+
background: $accent 60%;
175+
color: $text;
176+
}
182177
}
183178
"""
184179

src/textual/widgets/_select.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ class SelectOverlay(OptionList):
4747

4848
DEFAULT_CSS = """
4949
SelectOverlay {
50-
border: tall $background;
51-
background: $panel;
50+
border: tall $border-blurred;
51+
background: $surface;
5252
color: $text;
5353
width: 100%;
5454
padding: 0 1;
5555
}
5656
SelectOverlay:focus {
57-
border: tall $background;
57+
background-tint: $foreground 5%;
5858
}
5959
SelectOverlay > .option-list--option {
6060
padding: 0 1;
@@ -222,7 +222,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
222222
}
223223
224224
&:focus {
225-
background: $surface-active;
225+
background-tint: $foreground 5%;
226226
border: tall $border;
227227
}
228228
@@ -237,7 +237,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
237237
238238
&:focus {
239239
border: tall $border;
240-
background: $surface-active;
240+
background-tint: $foreground 5%;
241241
}
242242
}
243243

src/textual/widgets/_switch.py

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Switch(Widget, can_focus=True):
7070
}
7171
&:focus {
7272
border: tall $border;
73+
background-tint: $foreground 5%;
7374
}
7475
&:light {
7576
& > .switch--slider {

src/textual/widgets/_text_area.py

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class TextArea(ScrollView):
118118
119119
&:focus {
120120
border: tall $accent;
121+
background-tint: $foreground 5%;
121122
}
122123
123124
&:dark {

src/textual/widgets/_tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
607607
}
608608
609609
&:focus {
610-
background: $surface-active;
610+
background-tint: $foreground 5%;
611611
& > .tree--cursor {
612612
background: $highlight-cursor;
613613
}

0 commit comments

Comments
 (0)