radioSwitchButtons: Radio Switch Buttons

Description Usage Arguments Functions References Examples

View source: R/button-radio.R

Description

This input creates a radio switch that works like shiny::radioButtons() with the appearance of a button

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
radioSwitchButtons(inputId, label = NULL, choices,
  choice_labels = names(choices) %||% choices, selected = choices[1],
  selected_background = NULL, selected_color = NULL,
  not_selected_background = NULL, not_selected_color = NULL)

updateRadioSwitchButtons(inputId, selected = NULL,
  session = shiny::getDefaultReactiveDomain())

radioSwitchButtons_default_style(selected_background = NULL,
  selected_color = NULL, not_selected_background = NULL,
  not_selected_color = NULL)

radioSwitchButtonsDemo(display.mode = c("showcase", "normal", "auto"))

Arguments

inputId

The input id

label

The text to appear above the buttons (set to NULL for no label.)

choices

A vector of choices for the button group. The names will be used for button labels and the value are returned by the input. If an unnamed vector is provided, the button labels and values returned will be the same.

choice_labels

A list of labels for the choices that can be arbitrary HTML if wrapped in HTML(). Set to "" or NULL for no label.

selected

The value that should be active initially.

selected_background

Background color of the label when selected. Can be set globally via radioSwitchButtons_default_style(). Default value is "#007BFF".

selected_color

Text color of the label text when selected. Can be set globally via radioSwitchButtons_default_style(). Default value is "#FFFFFF".

not_selected_background

Background color of the label when not selected. Can be set globally via radioSwitchButtons_default_style(). Default value is "#FFFFFF".

not_selected_color

Text color of the label text when not selected. Can be set globally via radioSwitchButtons_default_style(). Default value is "#AAAAAA".

session

The session object passed to function given to shinyServer.

display.mode

The mode in which to display the application. If set to the value "showcase", shows application code and metadata from a DESCRIPTION file in the application directory alongside the application. If set to "normal", displays the application normally. Defaults to "auto", which displays the application in the mode given in its DESCRIPTION file, if any.

Functions

References

Adapted from CSS code by Mike Hemberger described in https://thestizmedia.com/radio-buttons-as-toggle-buttons-with-css/.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if (interactive()) {
library(shiny)
library(shinyThings)

ui <- fluidPage(
  inputPanel(
    radioSwitchButtons(
      inputId = "other",
      label = "Yes or No?",
      choices = c("Yes" = "yes", "No" = "no", "Maybe?" = "maybe"),
      selected_background = "#eb1455"
    ),

    radioSwitchButtons(
      inputId = "small",
      label = "Style",
      choices = c("plain", "bold", "italic"),
      choice_labels = list(
        tags$span(style = "font-weight: normal", "P"),
        tags$strong("B"),
        tags$em("I")
      )
    )
  ),
  verbatimTextOutput("values")
)

server <- function(input, output, session) {
  output$values <- renderPrint({
    str(list(
      moreThanTwo = input$other,
      style       = input$small
    ))
  })
}

shinyApp(ui, server)
}

gadenbuie/shinyThings documentation built on Nov. 24, 2019, 6:56 p.m.