Box and input inline in Shiny, but only for some inputs

前端 未结 1 1169
感动是毒
感动是毒 2021-01-25 17:47

I would like some inputs to have their label inline with the input box, and others to exhibit the standard Shiny standard behaviour. Consider the answer (and minimal example) gi

相关标签:
1条回答
  • 2021-01-25 18:36

    To achieve what you want you could modify the css as follows:

    tags$style(type="text/css", ".inline label{ display: table-cell; text-align: left; vertical-align: middle; } 
                     .inline .form-group{display: table-row;}")
    

    The code would look something like this:

    library(shiny)
    ui <- fluidPage(
      fluidRow(
        tags$head(
          tags$style(type="text/css", ".inline label{ display: table-cell; text-align: left; vertical-align: middle; } 
                     .inline .form-group{display: table-row;}")
          ),
        
        tags$div(class = "inline", textInput(inputId = "txtInp", label = "Label:"),
        textInput(inputId = "txtInp2", label = "Label2:")),
        numericInput(inputId = "numInp", label = "Third_label:", value = 0)
      )
    )
    
    server <- function(input, output){}
    shinyApp(ui, server)
    

    With this code you will get the labels which looks a lot cleaner, something like this:

    Hope it helps!

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