0

What kind of Shiny input widget can I use to implement a selector as in the picture? Is it an action button used?

enter image description here

z star
  • 684
  • 6
  • 19
  • 2
    Take 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 Answers2

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