how can I change the color of shinyWidgets::radioGroupButtons
Drop files here
or click to upload
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
titlePanel("RadioGroupButtons Color Demo"),
sidebarLayout(
sidebarPanel(
# Default colored buttons
radioGroupButtons(
inputId = "default",
label = "Default style",
choices = c("A", "B", "C"),
status = "default"
),
# Primary blue buttons
radioGroupButtons(
inputId = "primary",
label = "Primary blue style",
choices = c("A", "B", "C"),
status = "primary"
),
# Success green buttons
radioGroupButtons(
inputId = "success",
label = "Success green style",
choices = c("A", "B", "C"),
status = "success"
),
# Info light blue buttons
radioGroupButtons(
inputId = "info",
label = "Info light blue style",
choices = c("A", "B", "C"),
status = "info"
),
# Warning orange buttons
radioGroupButtons(
inputId = "warning",
label = "Warning orange style",
choices = c("A", "B", "C"),
status = "warning"
),
# Danger red buttons
radioGroupButtons(
inputId = "danger",
label = "Danger red style",
choices = c("A", "B", "C"),
status = "danger"
),
# Custom CSS styled buttons
radioGroupButtons(
inputId = "custom",
label = "Custom CSS style",
choices = c("A", "B", "C"),
status = "default"
)
),
mainPanel(
verbatimTextOutput("selected")
)
)
)
server <- function(input, output, session) {
output$selected <- renderPrint({
# Print all selected values
list(
Default = input$default,
Primary = input$primary,
Success = input$success,
Info = input$info,
Warning = input$warning,
Danger = input$danger,
Custom = input$custom
)
})
}
# Add custom CSS
tags$head(
tags$style(HTML("
/* Custom styling for the radio group buttons */
#custom .btn-group .btn {
background-color: #8e44ad;
color: white;
border-color: #7d3c98;
}
#custom .btn-group .btn.active {
background-color: #6c3483;
color: white;
border-color: #5b2c6f;
}
#custom .btn-group .btn:hover {
background-color: #7d3c98;
color: white;
border-color: #6c3483;
}
"))
)
shinyApp(ui = ui, server = server)
Hi! I can help you with any questions about Shiny and R. What would you like to know?