R Shinymaterial显示单选按钮

时间:2018-11-11 22:21:52

标签: shiny

在R Shiny中,可以使用here中的选项inline = TRUE来水平显示单选按钮,有没有办法通过shinymaterial package使用material_radio_button来做到这一点?

我尝试使用inline = TRUE并收到错误消息unused argument (inline = TRUE)

1 个答案:

答案 0 :(得分:0)

library(shiny)
library(shinymaterial)

ui <- fluidPage(
  material_radio_button(
    input_id = "example_radio_button",
    label = "Radio Button",
    choices = c(
      "Cake" = "c",
      "Pie" = "p",
      "Brownie" = "b"
    ),
    color = "#ef5350"
  ),

  tagList(
    tags$head(
      tags$style(
        "#example_radio_button {display: flex;}"
      )
    )
  )
)

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

}

shinyApp(ui, server)

您可以尝试display: flex;或将flex替换为-webkit-box-webkit-inline-boxinline-flex

更新

这看起来更好:

library(shiny)
library(shinymaterial)

ui <- fluidPage(
  tags$h5(tags$b('Radio Button')),
  material_radio_button(
    input_id = "example_radio_button",
    label = "",
    choices = c(
      "Cake" = "c",
      "Pie" = "p",
      "Brownie" = "b"
    ),
    color = "#ef5350"
  ),

  tagList(
    tags$head(
      tags$style(
        "#example_radio_button {display: flex;}
        input[type=radio] {margin-left: 10px;}"
      )
    )
  )
)

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

}

shinyApp(ui, server)