-
Notifications
You must be signed in to change notification settings - Fork 79
/
sticky-columns-selection.Rmd
94 lines (80 loc) · 1.68 KB
/
sticky-columns-selection.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: "Sticky Selection Column"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reactable)
```
### Using inline styles
```{r}
reactable(
MASS::Cars93,
selection = "multiple",
columns = list(
.selection = colDef(
style = list(position = "sticky", left = 0, background = "#fff", zIndex = 1),
headerStyle = list(position = "sticky", left = 0, background = "#fff", zIndex = 1),
width = 45
),
Manufacturer = colDef(
style = list(position = "sticky", left = 45, background = "#fff", zIndex = 1),
headerStyle = list(position = "sticky", left = 45, background = "#fff", zIndex = 1)
)
),
onClick = "select",
wrap = FALSE
)
```
### Using CSS
```{r sticky, eval=FALSE}
reactable(
MASS::Cars93,
selection = "multiple",
columns = list(
.selection = colDef(
class = "sticky left-col-1",
headerClass = "sticky left-col-1",
width = 45
),
Manufacturer = colDef(
class = "sticky left-col-2",
headerClass = "sticky left-col-2"
),
Model = colDef(
class = "sticky left-col-3",
headerClass = "sticky left-col-3"
)
),
onClick = "select",
wrap = FALSE
)
```
```{css}
.sticky {
position: sticky !important;
background: #fff;
z-index: 1;
}
.left-col-1 {
left: 0;
}
.left-col-2 {
left: 45px;
}
.left-col-3 {
left: 145px;
border-right: 1px solid #eee !important;
}
```
```{r ref.label="sticky", echo=FALSE}
```
```{css echo=FALSE}
/* rmarkdown html documents */
.main-container {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.main-container blockquote {
font-size: inherit;
}
```