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

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

问题描述

我有一个像这样的闪亮应用程序:

I've got a shiny application like this:

server.R:

    library(shiny)

    function(input, output) { NULL }

和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")
     )
    )

我想在其旁边(而不是上方)贴上selectInput的标签.你知道怎么做吗?

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)

如果您不想弄乱闪亮的默认CSS,可以将标签留空并在其旁边创建标签,而不必将现有标签放在一边.

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天全站免登陆