Create a switch input https://wikiki.github.io/form/switch/.

bulmaSwitchInput(
  inputId,
  label = NULL,
  value = FALSE,
  color = NULL,
  size = NULL,
  style = NULL,
  rtl = FALSE,
  disabled = FALSE
)

Arguments

inputId

Id to access value.

label

Switch label.

value

TRUE or FALSE, FALSE by default.

color

Switch color : link, info, primary, warning, danger, success, black, dark and ligth.

size

Switch size : small, medium and large.

style

Switch style : thin, rounded, outlined or mixed1, mixed2, mixed3 and mixed4 (mixed1 is thin-rounded, mixed2 is thin-outlined, mixed3 is rounded-outlined and mixed4 is thin-rounded-outlined) NULL by default, which corresponds to squared style.

rtl

Set to invert switch.

disabled

Set to disable switch.

Author

David Granjon, dgranjon@ymail.com

Examples

if(interactive()) {
library(shiny)

shinyApp(
 ui = bulmaNavbarPage(
   bulmaNavbar(
     bulmaNavbarBrand(
       bulmaNavbarItem(
         "shinybulma"
       ),
       bulmaNavbarBurger()
     ),
     bulmaNavbarMenu( # not visible on smaller devices
       bulmaNavbarItem(
         "Switch Inputs"
       )
     )
   ),
   bulmaNav(
     "Switch Inputs",
     div(style = "text-align: center;",
         bulmaTitle("The plot only displays if switch 1 is TRUE.")),
     
     br(), br(), hr(),
     
     bulmaContainer(
       bulmaColumns(
         bulmaColumn(
           width = 6,
           bulmaSubtitle("Inputs"),
           bulmaSwitchInput(
             inputId = "switch1", 
             label = "switch 1", 
             value = FALSE,
             color = NULL, 
             size = NULL, 
             style = NULL,
             rtl = FALSE, 
             disabled = FALSE),
           
           bulmaSwitchInput(
             inputId = "switch2", 
             label = "switch 2", 
             value = TRUE,
             color = "warning", 
             size = "large", 
             style = "rounded",
             
             rtl = FALSE, 
             disabled = TRUE),
           
           bulmaSwitchInput(
             inputId = "switch3", 
             label = "switch 3", 
             value = TRUE,
             
             color = "danger", 
             size = "small", 
             style = "thin",
             
             rtl = FALSE, 
             disabled = FALSE),
           
           bulmaSwitchInput(
             inputId = "switch4", 
             label = "switch 4", 
             value = FALSE,
             
             color = NULL, 
             size = NULL, 
             style = "mixed3",
             rtl = FALSE, 
             disabled = FALSE)
         ),
         bulmaColumn(
           width = 6,
           bulmaSubtitle("Outputs"),
           plotOutput("plot1"),
           uiOutput("switches")
         )
       )
     )
   )
 ),
 server = function(input, output) {
   
   output$plot1 <- renderPlot({
     if (input$switch1 == TRUE) {
       plot(mtcars$wt, mtcars$mpg)
     }
   })
   
   output$switches <- renderPrint({
     c(input$switch1, input$switch2, input$switch3, input$switch4)
   })
 }
 )
}