2017-07-18 33 views
0

我在Shiny中有一个selectInput小部件。如何分别控制字体大小风格的标签和选择文本s​​electInput在Shiny中?

要控制的字体大小分别同时为label参数,以及用于小部件本身的输入文本(即,的choicesselected参数的文本)。

初始[样式更少]输出看起来是这样的:

selectInput(inputId = "inId", label = "Different Font Size...", choices = "...From This") 

enter image description here

我尝试使用div()像这样:

div(style = "font-size: 8px", 
    selectInput(inputId = "inId", label = "Different Font Size...", choices = "...From This") 

) 

哪个缩小双方label文字和输入文字(即choices的文字)。

enter image description here

  • 注:这是在对比使用这种方法div(style = ...)textInput,这不是仅仅影响了label文本(而不是输入文字)。

    • 在这种情况下,我会然后使用tags$style("#inId {font-size:8px;}")textInput函数分别修改输入字体大小。

      div(style = "font-size: 8px", 
          textInput(inputId = "inId", label = "Different Font Size...", value = "...From This") 
      ), tags$style("#inId {font-size:14px;}") 
      

然而,这并不使用selectInput()工作。

  • 指定一个tag$style(...)下一个div(style = ...)包装似乎并没有做任何事情来得到的文本样式。

    div(style = "font-size: 8px", 
         selectInput(inputId = "inId", label = "Different Font Size...", choices = "...From This") 
    ), tags$style("#inId {font-size:14px;}") 
    ) 
    

那么,如何做到这一点?

我如何控制文本样式(特别是字体大小)分别labelchoices文字使用有光泽selectInput小部件?

  • 同样,我的目标是实现做以下的能力:

    enter image description here


如果它的事项:我使用shiny_1.0.3与R版本3.4.0

回答

1

你可以包装p整个selectInput()以及标签本身div()具有单独的字体大小。标签的样式将覆盖外部div的样式。

shinyApp(
    ui = fluidPage(
    div(style = "font-size:20px;", 
     selectInput(inputId = "inId", label = div(style = "font-size:80px", "Different Font Size..."), 
        choices = c("...From This", "Test") 
       ) 
    ) 
), 
    server = function(input, output) { 

    } 
) 

我希望这有助于。
干杯

相关问题