简体   繁体   中英

Remove bold in a shiny sidebar in R

I'm new to Shiny and can't figure out how to "unbold" labels (feed rate and operation in the screenshot attached). Here's my code for the UI part:

ui <- fluidPage(titlePanel(""),
                sidebarLayout(
                  sidebarPanel(
                    # adding the new div tag to the sidebar            
                    tags$div(class="header", checked=NA,
                             tags$h4(strong("Duty"))),
                    selectInput('id1', 'Feed rate (m^3/h)', c("All", main$metric[1:3])),
                    selectInput('id2', 'Operation', c("All", main$metric[4:5])),
                  mainPanel(DT::dataTableOutput("table"))
                ))

And here's the screenshot:

在此处输入图片说明

You can do this by adding your own style sheet to your Shiny app. First we give the sidebar panel a class sidebar so we can refer to it. Then we can add the following to a file www/style.css :

.sidebar label {
  font-weight: 400;
}

Finally we set the theme parameter of your fluidPage to "style.css".

ui <- fluidPage(theme="style.css", titlePanel(""),
   # content here
))

The result should look like this:

在此处输入图片说明

This is another option (you don't have to create a file)

library(shiny)

remove_bold <-"
#expr-container label {
  font-weight: 400;
}
"

ui <- fluidPage(
  
  titlePanel("My app"),
  
  sidebarLayout(
    sidebarPanel(
      tags$style(remove_bold), ####### NEW CODE
      tags$div(id = "expr-container", ####### NEW CODE
      textInput(inputId = "data2", "Data1", value = "data"))
    ),
    
    mainPanel(
    )
  )
)


server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

Inspired in this post: How to change the pickerinput label to fine instead of bold

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM