Pry*_*ore 2 css r shiny shinydashboard tablehtml
这一定是一个简单的问题,但我还没有找到任何关于更改 ShinyDashboard 框中文本的大小、字体和颜色的脚本或建议。比如说,我想让这个框显示 14px Arial 灰色文本:
box(width = 4, title = "sample", "this is a test")
Run Code Online (Sandbox Code Playgroud)
我想这需要 css,但是有什么方法可以使用 Shiny 的内置函数来实现这一点?
非常感谢。
您需要更改框的 CSS 才能使其正常工作。您可以直接在 ui 中传递 CSS,使用tableHTML::make_css. 函数box创建一个名为“box”的 HTML 类,您可以使用它来更改框的 CSS:
library(shiny)
library(tableHTML)
ui <- fluidPage(
tags$style(make_css(list('.box',
c('font-size', 'font-family', 'color'),
c('14px', 'arial', 'red')))),
box(width = 4, title = "sample", "this is a test")
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
输出:
我把文字改成了红色,这样你就可以很容易地分辨出与黑色的区别。您可以将其替换为灰色或您想要的任何颜色。