0

我正在使用带有选项 individual = TRUE 的 shinyWidgets 包的“radioGroupButtons”。按钮紧密并排放置。

我有两个问题。是否有可能在按钮之间获得更多空间?是否也可以获取带有图标(Glyphicon,Font Awesome)的按钮标签?

如果它看起来像这样,那就太好了:

在此处输入图像描述

我的代码如下:

library(shiny)
library(shinyjs)
library(shinyWidgets)

ui <- fluidPage(
  useShinyjs(),

  radioGroupButtons(
    inputId = "id000",
    label = NULL,
    choices = c("Text",  "File", "Web"),
    individual = TRUE,
    selected = character(0))
)

server <- function(input, output, session)
{
  observeEvent(input$id000, alert(input$id000), ignoreInit = TRUE)
}

shinyApp(ui = ui, server = server)
4

1 回答 1

1

这应该有效:

library(shiny)
library(shinyjs)
library(shinyWidgets)

ui <- fluidPage(
  useShinyjs(),
  tags$head(tags$style('.btn-group{ margin-left: 15px;}')),  # add the spacing
  icon(NULL),  # need a call to icon to attach some dependencies; probably a better solution exists
  radioGroupButtons(
    inputId = "id000",
    label = NULL,
    choices = c(`<i class='fas fa-font'></i> Text` = "Text",
                `<i class='far fa-file-alt'></i> File` = "File", 
                `<i class='fas fa-globe-americas'></i> Web` = "Web"),
    individual = TRUE,
    selected = character(0))
)

server <- function(input, output, session)
{
  observeEvent(input$id000, alert(input$id000), ignoreInit = TRUE)
}

shinyApp(ui = ui, server = server)

要查找更多图标,请查看 中的链接?icon

于 2020-01-16T14:56:20.377 回答