我正在使用ShinyWidgets软件包的'radioGroupButtons',并使用选项personal = TRUE。按钮紧密并排放置。
我有两个问题。是否可以在按钮之间获得更多的空间?也可以在按钮标签前面加上一个图标(Glyphicon,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)
这应该起作用:
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)