What kind of Shiny input widget can I use to implement a selector as in the picture? Is it an action button used?
Asked
Active
Viewed 154 times
0
-
2Take a look at package `shinyWidgets` and `radioGroupButtons` [here](https://www.rdocumentation.org/packages/shinyWidgets/versions/0.5.3/topics/radioGroupButtons) – Ben Sep 28 '20 at 15:17
2 Answers
1
This is most probably a radioButtons element styled with CSS. Here is an example how to apply this kind of formatting to radio buttons: https://stackoverflow.com/a/4642152/14327549

hundertdrei
- 106
- 6
1
With package shinyWidgets and a bit of CSS you can achieve the same result:
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h1("Active background color for radioGroupButtons"),
tags$style(
".btn-custom.active, .btn-custom:active, .btn-custom:focus, .btn-custom:hover {
background: #4B088A !important;
color: #FFF !important;
}",
".btn-custom {border-color: #4B088A; color: #4B088A; background: #FFF;}"
),
radioGroupButtons(
inputId = "somevalue",
label = NULL,
choices = c("All cases", "Active cases"),
status = "custom"
),
verbatimTextOutput("value")
)
server <- function(input, output) {
output$value <- renderPrint({ input$somevalue })
}
shinyApp(ui, server)

Victorp
- 13,636
- 2
- 51
- 55