Changing the font size of valueBoxes

前端 未结 1 1772
北海茫月
北海茫月 2021-02-04 15:21

I would like to change the font size of the value and the subtitle for valueBoxes.

Below is my attempt, but would be grateful of any suggestions on how to c

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 16:04

    Hi you can change font size directly in valueBox with a p tag without rewriting valueBox function (if you want you can, just wrap value and subtitle args in tags$p), try :

    library("shiny")
    library("shinydashboard")
    
    # header
    header <- dashboardHeader(title = "Changing the font size of valueBoxes", titleWidth = 450)
    
    # sidebar
    sidebar <- dashboardSidebar(disable = TRUE)
    
    # body
    body <- dashboardBody(
      valueBox(
        value = "90k",
        subtitle = "some long descritptive text",
        icon = icon("car")
      ),
      valueBox(
        value = tags$p("90k", style = "font-size: 150%;"),
        subtitle = tags$p("some long descritptive text", style = "font-size: 150%;"),
        icon = icon("car fa-lg")
      ),
      valueBox(
        value = tags$p("90k", style = "font-size: 200%;"),
        subtitle = tags$p("some long descritptive text", style = "font-size: 200%;"),
        icon = icon("car fa-2x")
      ),
      valueBoxOutput(outputId = "mybigbox")
    )
    
    # server
    server <- function(input, output) {
      output$mybigbox <- renderValueBox({
        valueBox(
          value = tags$p("90k", style = "font-size: 300%;"),
          subtitle = tags$p("some long descritptive text", style = "font-size: 300%;"),
          icon = icon("car fa-3x")
        )
      })
    }
    shinyApp(ui = dashboardPage(header, sidebar, body), server = server)
    

    0 讨论(0)
提交回复
热议问题