简体   繁体   中英

Changing the distance between the label text and a selectizeInput element in R Shiny?

I'm looking for a way to adjust the label space on selectizeInput elements in a Shiny app. The different spacing is a result of inserting a checkbox to the label.

I already found a hint here , but this only helps little. Here is an example:

library(shiny)

    ui <- fluidPage(
  tags$head(
    tags$style(HTML(
      "label { margin-bottom: 0px; }"
    ))
  ),
  fluidRow(
    column(2,
           selectizeInput("S1", label = checkboxInput(inputId = "chk1", label = p('Test - ', strong('Test:'))), c("A","B")),
           selectizeInput("S2", label = checkboxInput(inputId = "chk2", label = div(icon("filter"), strong('Test:'))), c("A", "B")),
           selectizeInput("S3", "Test:", c("A", "B")),
           selectizeInput("S4", "Test:", c("A", "B"))
    )))

server <- function(input, output){}

shinyApp(ui = ui, server = server)

This is the result

Thanks!

I think that should do it.

library(shiny)

ui <- fluidPage(
  tags$head(
    tags$style(HTML(
       ".checkbox {margin: 0}
        .checkbox p {margin: 0;}
        .shiny-input-container {margin-bottom: 0;}
       "
    ))
    # inlineCSS(".checkbox margin: 0;")
  ),
  fluidRow(
    column(2,
           selectizeInput("S1", label = checkboxInput(inputId = "chk1", label = p('Test - ', strong('Test:'))), c("A","B")),
           selectizeInput("S2", label = checkboxInput(inputId = "chk2", label = div(icon("filter"), strong('Test:'))), c("A", "B")),
           selectizeInput("S3", "Test:", c("A", "B")),
           selectizeInput("S4", "Test:", c("A", "B"))
    )))

server <- function(input, output){}

shinyApp(ui = ui, server = server)

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