Skip to content

Commit fb7fb60

Browse files
committed
Various DataTable style fixes - fix text colors, fixed header styling in themes
1 parent e3d0fd2 commit fb7fb60

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

examples/theme_sandbox.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ def compose(self) -> ComposeResult:
436436
table.add_columns(*HEADERS)
437437
table.add_rows(ROWS)
438438
table.zebra_stripes = True
439+
table.fixed_columns = 1
440+
table.cursor_type = "row"
439441
yield table
440442
yield ListView(
441443
ListItem(Label("One")),

src/textual/widgets/_data_table.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
319319
color: $foreground;
320320
height: auto;
321321
max-height: 100%;
322+
323+
&.datatable--fixed-cursor {
324+
background: $block-cursor-blurred-background;
325+
}
322326
323327
&:focus {
324328
background-tint: $foreground 5%;
@@ -331,12 +335,17 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
331335
& > .datatable--header {
332336
background-tint: $foreground 5%;
333337
}
338+
339+
& > .datatable--fixed-cursor {
340+
color: $block-cursor-foreground;
341+
background: $block-cursor-background;
342+
}
334343
}
335344
336345
&:dark {
337346
background: $surface;
338347
& > .datatable--even-row {
339-
background: $surface-lighten-1 50%;
348+
background: $surface-darken-1 40%;
340349
}
341350
}
342351
@@ -352,7 +361,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
352361
353362
& > .datatable--fixed {
354363
background: $secondary 50%;
355-
color: $text;
364+
color: $foreground;
356365
}
357366
358367
& > .datatable--odd-row {
@@ -370,13 +379,13 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
370379
}
371380
372381
& > .datatable--fixed-cursor {
373-
background: $block-cursor-background;
374-
color: $text;
382+
background: $block-cursor-blurred-background;
383+
color: $foreground;
375384
}
376385
377386
& > .datatable--header-cursor {
378387
background: $accent-darken-1;
379-
color: $text;
388+
color: $foreground;
380389
}
381390
382391
& > .datatable--header-hover {

0 commit comments

Comments
 (0)