Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

materialSwitch

Material Design Switch Input Control


Description

A toggle switch to turn a selection on or off.

Usage

materialSwitch(
  inputId,
  label = NULL,
  value = FALSE,
  status = "default",
  right = FALSE,
  inline = FALSE,
  width = NULL
)

Arguments

inputId

The input slot that will be used to access the value.

label

Input label.

value

TRUE or FALSE.

status

Color, must be a valid Bootstrap status : default, primary, info, success, warning, danger.

right

Should the the label be on the right? default to FALSE.

inline

Display the input inline, if you want to place buttons next to each other.

width

The width of the input, e.g. '400px', or '100%'.

Value

A switch control that can be added to a UI definition.

See Also

Examples

if (interactive()) {
  library(shiny)
  library(shinyWidgets)

  ui <- fluidPage(
    tags$h3("Material switch examples"),

    materialSwitch(inputId = "switch1", label = "Night mode"),
    verbatimTextOutput("value1"),

    materialSwitch(inputId = "switch2", label = "Night mode", status = "danger"),
    verbatimTextOutput("value2")
  )
  server <- function(input, output) {

    output$value1 <- renderText({ input$switch1 })

    output$value2 <- renderText({ input$switch2 })

  }
  shinyApp(ui, server)
}

shinyWidgets

Custom Inputs Widgets for Shiny

v0.6.0
GPL-3
Authors
Victor Perrier [aut, cre, cph], Fanny Meyer [aut], David Granjon [aut], Ian Fellows [ctb] (Methods for mutating vertical tabs & updateMultiInput), Wil Davis [ctb] (numericRangeInput function), Spencer Matthews [ctb] (autoNumeric methods), JavaScript and CSS libraries authors [ctb, cph] (All authors are listed in LICENSE.md)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.