bulmaSwitchInput: Add switch input

Description Usage Arguments Author(s) Examples

View source: R/bulma-input.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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(s)

David Granjon, dgranjon@ymail.com

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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)
   })
 }
 )
}

JohnCoene/shinybulma documentation built on Oct. 17, 2020, 8:57 p.m.