chakraAlertDialog: Alert dialog widget

Description Usage Arguments Details Value Examples

View source: R/chakraAlertDialog.R

Description

An alert dialog widget.

Usage

1
2
3
4
5
6
7
8
chakraAlertDialog(
  inputId,
  options = chakraAlertDialogOptions(),
  openButton,
  header,
  body,
  footer
)

Arguments

inputId

widget id

options

named list of options created with chakraAlertDialogOptions

openButton

a Chakra button to open the alert dialog

header

an AlertDialogHeader element

body

an AlertDialogBody element

footer

an AlertDialogFooter element; usually it contains some Chakra buttons (that you can group with Tag$ButtonGroup(...))

Details

You can use an action attribute and a value attribute to the Chakra buttons you put in the widget. For example, if you include the Chakra button Tag$Button("Cancel", action = "cancel", value = "CANCEL"), clicking this button will cancel the alert dialog and will set the Shiny value "CANCEL". Other possible action attributes are "close" to close the alert dialog, "disable" to disable the alert dialog, and "remove" to entirely remove the widget.

Value

A widget that can be used in chakraComponent.

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

ui <- chakraPage(

  br(),

  chakraComponent(
    "mycomponent",

    chakraAlertDialog(
      inputId = "alertDialog",
      openButton = Tag$Button(
        leftIcon = Tag$DeleteIcon(),
        colorScheme = "red",
        "Delete customer"
      ),
      header = Tag$AlertDialogHeader(
        fontSize = "lg",
        fontWeight = "bold",
        "Delete customer?"
      ),
      body = Tag$AlertDialogBody(
        "Are you sure? You can't undo this action afterwards."
      ),
      footer = Tag$AlertDialogFooter(
        Tag$ButtonGroup(
          spacing = "3",
          Tag$Button(
            action = "cancel",
            value = "CANCEL",
            "Cancel"
          ),
          Tag$Button(
            action = "disable",
            value = "DISABLE",
            colorScheme = "red",
            "Disable"
          ),
          Tag$Button(
            action = "remove",
            value = "REMOVE",
            "Remove"
          )
        )
      )
    )

  )

)

server <- function(input, output, session){

  observe({
    print(input[["alertDialog"]])
  })

}

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

shinyChakraUI documentation built on Jan. 5, 2022, 5:08 p.m.