How to change the fonts size of sidebar in shinydashboard

最后都变了- 提交于 2019-12-02 04:34:29

If you just want to change the font size of the sidebar here is the code :

library('shinydashboard')
library(shiny)
ui <- dashboardPage(
 dashboardHeader(title = 'Test'),
 dashboardSidebar(
   sidebarMenu(
     menuItem('Tab1', tabName = '1', icon = icon('dashboard')),
     menuItem('Tab2', tabName = '2', icon = icon('th'))
   )),
 dashboardBody(
  tags$head( 
    tags$style(HTML(".main-sidebar { font-size: 20px; }")) #change the font size to 20
   ),
tabItems(
#First tab content
tabItem(tabName = '1',
        fluidRow(
          box(plotOutput('plot1', height = 250)),
          box(tilte = 'Controls',
              sliderInput('slider', 'Number of obs', 1, 100, 50))
        )),
#Second tab content
tabItem(tabName = '2',
        h2('Some text here'))
  ))
)

server <- function(input, output) {
 set.seed(122)
 histdata <- rnorm(500)
 output$plot1 <- renderPlot({
   data <- histdata[seq_len(input$slider)]
   hist(data)
  })
 }
 shinyApp(ui, server)

However, if you want to do more changes in CSS I advise you to create a css file and call it in your shiny app with the following code : tags$head(includeCSS(path =www/style.css")).

You can find more details and tutorial here : https://shiny.rstudio.com/articles/css.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!