我使用可反应包创建了一个表格,但我不确定如何格式化 HTML 标题,以便它们与表格共享相同的样式,例如字体、颜色和背景颜色。我希望它看起来像一个整体,而不是看起来不合适。
这是我的代码:
library(reactable)
library(htmltools)
options(reactable.theme = reactableTheme(
color = "hsl(233, 9%, 87%)",
backgroundColor = rgb(38/255,42/255,51/255,142/240),
borderColor = rgb(152/255,156/255,165/255,240/240)
))
example<- reactable(data.frame(country=c("argentina","brazil"),
value=c(1,2)
))
final <- htmlwidgets::prependContent(example,
list(h2(class = "title", "title 1"),
h4(class = "subtitle", "subtitle")))
print(final)
你会做什么?
使用
htmltools::tags$style
创建样式标签,然后您可以编写要应用于标题的CSS
htmlwidgets::prependContent(
final,
htmltools::tags$style(
"h2, h4 {color:hsl(233, 9%, 87%)"
)
)