如何包装checkboxGroupInput的输出?

时间:2019-01-23 08:30:23

标签: css r shiny

如何修改以下代码,以使'checkboxGroupInput'选项包含在'width:200px'中?

library(shiny)

ui <- fluidPage(
  tags$style("
      .custom-wrap {
        display: flex;
        flex-flow: wrap;
        flex-direction: column;
        width: 200px;
      }
      "
  ),
  div(class = "custom-wrap",checkboxGroupInput("variable", "Variables to show:",
                                    c("Cylinders" = "cyl",
                                      "Transmission" = "am",
                                      "Gears" = "gear")))
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

1 个答案:

答案 0 :(得分:1)

如果要选择checkboxGroupInput的所有子代,请使用此选择器#variable *

library(shiny)

ui <- fluidPage(
  tags$style("
      #variable * {
        display: flex;
        flex-flow: wrap;
        flex-direction: column;
        width: 200px;
      }
      "
  ),
  checkboxGroupInput("variable", "Variables to show:",
                     c("Cylinders" = "cyl",
                       "Transmission" = "am",
                       "Gears" = "gear")))

server <- function(input, output, session) {

}

shinyApp(ui, server)