我想调整reactable
中列中特定单元格的左填充。我可以让它为color
工作(基于这个answer),但不是填充。有什么想法吗
MWE
library(reactable)
library(dplyr)
df <- iris |>
group_by(Species) |>
slice(1:3) |>
select(Species, Sepal.Length)
reactable::reactable(df,
columns = list(
Species = colDef(align = "left",
style = function(value, index) {
if (df$Species[index] == "setosa") {
paddingLeft <- "padding-left: 10px;"
color <- "red"
} else if (df$Species[index] == "versicolor") {
paddingLeft <- "padding-left: 30px !important;"
color <- "green"
} else {
paddingLeft <- "padding-left: 1px;"
color <- "black"
}
list(paddingLeft = paddingLeft, color = color)
})
))
1条答案
按热度按时间8ulbf1ek1#
与
color
类似,只将值传递给paddingLeft
: