
Last chance! 50% off unlimited learning
Sale ends in
Create a toggle switch.
switchInput(inputId, label = NULL, value = FALSE, onLabel = "ON",
offLabel = "OFF", onStatus = NULL, offStatus = NULL, size = "default",
labelWidth = "auto", handleWidth = "auto", disabled = FALSE,
inline = FALSE, width = NULL)
The input
slot that will be used to access the value.
Display a text in the center of the switch.
Initial value (TRUE or FALSE).
Text on the left side of the switch (TRUE).
Text on the right side of the switch (FALSE).
Color (bootstrap status) of the left side of the switch (TRUE).
Color (bootstrap status) of the right side of the switch (FALSE).
Size of the buttons ('default', 'mini', 'small', 'normal', 'large').
Width of the center handle in pixels.
Width of the left and right sides in pixels.
Logical, display the toggle switch in disabled state?.
Logical, display the toggle switch inline?
The width of the input : 'auto', 'fit', '100px', '75%'.
A switch control that can be added to a UI definition.
# NOT RUN {
## Only run examples in interactive R sessions
if (interactive()) {
# Examples in the gallery :
shinyWidgets::shinyWidgetsGallery()
# Basic usage :
ui <- fluidPage(
switchInput(inputId = "somevalue"),
verbatimTextOutput("value")
)
server <- function(input, output) {
output$value <- renderPrint({ input$somevalue })
}
shinyApp(ui, server)
}
# }
Run the code above in your browser using DataLab