multiActionButton: Multi action button

Description Usage Arguments Examples

View source: R/main.R

Description

Creates a multi action button for usage in a Shiny UI.

Usage

1
2
3
4
5
6
7
8
multiActionButton(
  rotate = TRUE,
  bg = NULL,
  fg = NULL,
  icon = NULL,
  direction = "right",
  subButtons
)

Arguments

rotate

logical, whether to rotate the icon upon clicking the main button

bg

background color of the button

fg

color of the icon

icon

icon name

direction

the opening direction, "top", "right", "bottom", or "left"

subButtons

a list of buttons created with subButton

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
library(shiny)
library(shinyMultiActionButton)

ui <- fluidPage(

  tags$head(
    tags$style(HTML("pre {font-size: 18px; font-weight: bold;}"))
  ),

  br(),

  multiActionButton(
    rotate = TRUE, bg = "darkMagenta", fg = "white",
    icon = "plus", direction = "right",
    subButtons = list(
      subButton("user-plus", bg = "blue", icon = "user-plus", iconSize = "4x"),
      subButton("library", bg = "teal", icon = "library", iconSize = "4x"),
      subButton("alarm", bg = "pink", icon = "alarm", iconSize = "4x"),
      subButton("power", bg = "lime", icon = "power", iconSize = "4x"),
      subButton("lock", bg = "orange", icon = "lock", iconSize = "4x")
    )
  ),

  br(), br(), br(),

  tags$fieldset(
    tags$legend("Buttons states"),
    verbatimTextOutput("buttons")
  )

)


server <- function(input, output){

  output[["buttons"]] <- renderPrint({
    states <- c(
      paste0("user-plus: ", input[["user-plus"]]),
      paste0("library: ", input[["library"]]),
      paste0("alarm: ", input[["alarm"]]),
      paste0("power: ", input[["power"]]),
      paste0("lock: ", input[["lock"]])
    )
    cat(states, sep = "\n")
  })

}

if(interactive()){
  shinyApp(ui, server)
}

stla/shinyMultiActionButton documentation built on Sept. 5, 2020, 5:58 p.m.