出现流体行问题,并在Shiny

时间:2017-11-02 23:29:09

标签: r user-interface shiny

我在格式化一行动态输入时遇到问题。无论何时我将checkboxInput作为fluidRow的一部分,它都会跳转到一个新行,而不是将操作按钮直接放在复选框的右侧。知道我可能做错了吗?

enter image description here

以下是当前代码:



  #Dynamic UI based on how many cohorts exist;
  cohort_ui = eventReactive(c(input$save_cohort, input$reset_cohorts, input$delete_cohort1, input$delete_cohort2), {
    bootstrapPage(
      strong("Combine Cohorts"),
      lapply(1:length(names(cohorts)), function(i) {
        fluidRow(column(width = 12, checkboxInput(paste0("active_cohort",i), label = names(cohorts)[i], value = FALSE), 
                        actionButton(paste0("delete_cohort",i), "Delete"), actionButton(paste0("rename_cohort",i), "Rename"), 
                        textInputRow(paste0("rename_cohort_text",i), label= NULL, placeholder = "Enter new cohort name")))
      }),
      radioButtons("join_cohorts", label = "Join Operation", choices = c("Union", "Intersection", "Difference"), selected = NULL),
      textInput("join_cohorts_name", label = "New Cohort Name", value = "", width = NULL, placeholder = NULL),
      actionButton("join_cohorts_save", "Save")
    )
  })
  output$cohort_ui = renderUI({cohort_ui()})




1 个答案:

答案 0 :(得分:1)

这是因为复选框是块级元素。您需要添加css以使其内联。简短的例子:

library(shiny)

mycss <- "
.mycheckbox .shiny-input-container {
  display: inline-block;
  width: auto;
}
"

ui <- fluidPage(
  tags$style(mycss),
  span(class="mycheckbox", checkboxInput("checkbox", "checkbox")),
  actionButton("button", "button")
)

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

shinyApp(ui, server)