Skip to content

Commit a47b157

Browse files
committed
New: Dark mode support for DataTables and Bootstrap 5.3+ styling
1 parent 91f5509 commit a47b157

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

css/scroller.bootstrap5.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@
33
div.DTS div.dataTables_scrollBody table {
44
// Don't have transparent rows
55
background-color: white;
6-
}
6+
}
7+
8+
html[data-bs-theme="dark"] {
9+
div.DTS div.dataTables_scrollBody table {
10+
// Don't have transparent rows
11+
background-color: var(--bs-body-bg);
12+
}
13+
}

css/scroller.dataTables.scss

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ div.dts {
1515

1616
div.dts_label {
1717
position: absolute;
18-
right: 10px;
18+
right: 20px;
1919
background: rgba(0, 0, 0, 0.8);
2020
color: white;
2121
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
@@ -29,10 +29,10 @@ div.dts {
2929
div.dataTables_scrollBody {
3030
background: repeating-linear-gradient(
3131
45deg,
32-
#edeeff,
33-
#edeeff 10px,
34-
white 10px,
35-
white 20px
32+
rgba(0, 0, 0, 0.025),
33+
rgba(0, 0, 0, 0.025) 10px,
34+
rgba(0, 0, 0, 0) 10px,
35+
rgba(0, 0, 0, 0) 20px
3636
);
3737

3838
table {
@@ -48,3 +48,27 @@ div.dts {
4848
display: none;
4949
}
5050
}
51+
52+
html.dark {
53+
div.dts {
54+
div.dts_label {
55+
background: rgba(255, 255, 255, 0.8);
56+
color: black;
57+
}
58+
59+
div.dataTables_scrollBody {
60+
background: repeating-linear-gradient(
61+
45deg,
62+
rgba(255, 255, 255, 0.025),
63+
rgba(255, 255, 255, 0.025) 10px,
64+
rgba(255, 255, 255, 0) 10px,
65+
rgba(255, 255, 255, 0) 20px
66+
);
67+
68+
table {
69+
background-color: var(--dt-html-background);
70+
z-index: 2;
71+
}
72+
}
73+
}
74+
}

js/dataTables.scroller.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,6 @@ $.extend(Scroller.prototype, {
10581058
this.dom.label
10591059
.html(this.s.dt.fnFormatNumber(parseInt(this.s.topRowFloat, 10) + 1))
10601060
.css('top', iScrollTop + iScrollTop * labelFactor)
1061-
.css('right', 10 - this.dom.scroller.scrollLeft)
10621061
.css('display', 'block');
10631062
}
10641063
},

0 commit comments

Comments
 (0)