闪亮的 selectInput 旁边的标签 [英] Label next to selectInput in shiny

查看:37
本文介绍了闪亮的 selectInput 旁边的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I've got a shiny application like this:

server.R:

    library(shiny)

    function(input, output) { NULL }

and ui.R:

    library(shiny)  


    pageWithSidebar( 

       headerPanel("side-by-side"), 

     fluidRow(

        column(2),
        column(4,
           wellPanel(
               selectInput(inputId = "options", label = "some text", 
                           choices = list(a = 0, b = 1)))   
           )
      ),

      fluidRow( 
         h3("bla bla")
     )
    )

And I would like to have the label of selectInput next to it, not above. Do you know how to do it?

I've found this: Positioning Shiny widgets beside their headers but it doesn't work for me.

解决方案

There's multiple ways of doing this, here's one:

library(shiny)

server <- shinyServer(function(input, output) { NULL })
ui <- shinyUI(
  pageWithSidebar( 

    headerPanel("side-by-side"), 

    sidebarPanel(
    fluidRow(
      tags$head(
        tags$style(type="text/css", "label.control-label, .selectize-control.single{ display: table-cell; text-align: center; vertical-align: middle; } .form-group { display: table-row;}")
      ),
      column(2),
      column(4,
               selectInput(inputId = "options", label = "some text", 
                           choices = list(a = 0, b = 1))
      )
    )),
    mainPanel(
    fluidRow( 
      h3("bla bla")
    ))
  )
)

shinyApp(ui=ui,server=server)

If you don't want to mess with shinys default CSS you can just leave the label empty and create a label next to it instead of forcing the existing label to the side.

这篇关于闪亮的 selectInput 旁边的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆