5.5 主题
在页面函数中都会有参数theme
,你可根据bslib::bs_theme()
函数传入预制的主题。
或者可自定义主题
除了页面主题,输出的图像也能凭借thematic::thematic_shiny()
设置自适应主题,
library(ggplot2)
ui <- fluidPage(
theme = bslib::bs_theme(bootswatch = "darkly"),
titlePanel("A themed plot"),
plotOutput("plot"),
)
server <- function(input, output, session) {
thematic::thematic_shiny()
output$plot <- renderPlot({
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
geom_smooth()
}, res = 96)
}
更进一步,如果你了解HTML和CSS,那么你完全可以自定义主题,详见此处。