inputSweetAlert: Launch an input text dialog

Description Usage Arguments See Also Examples

Description

Launch a popup with a text input

Usage

1
2
3
4
inputSweetAlert(session, inputId, title = NULL, text = NULL,
  type = NULL, input = c("text", "password", "textarea", "radio",
  "checkbox", "select"), inputOptions = NULL, inputPlaceholder = NULL,
  btn_labels = "Ok", btn_colors = NULL, ...)

Arguments

session

The session object passed to function given to shinyServer.

inputId

The input slot that will be used to access the value.

title

Title of the pop-up.

text

Text of the pop-up.

type

Type of the pop-up : "info", "success", "warning", "error" or "question".

input

Type of input, possible values are : "text", "password","textarea", "radio", "checkbox" or "select".

inputOptions

Options for the input. For "radio" and "select" it will be choices.

inputPlaceholder

Placeholder for the input, use it for "text" or "checkbox".

btn_labels

Label(s) for button(s).

btn_colors

Color(s) for button(s).

...

Additional arguments (not used)

See Also

sendSweetAlert, confirmSweetAlert

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
if (interactive()) {
  library("shiny")
  library("shinyWidgets")


  ui <- fluidPage(
    tags$h1("Confirm sweet alert"),
    actionButton(inputId = "text", label = "Text Input"),
    verbatimTextOutput(outputId = "text"),
    actionButton(inputId = "password", label = "Password Input"),
    verbatimTextOutput(outputId = "password"),
    actionButton(inputId = "radio", label = "Radio Input"),
    verbatimTextOutput(outputId = "radio"),
    actionButton(inputId = "checkbox", label = "Checkbox Input"),
    verbatimTextOutput(outputId = "checkbox"),
    actionButton(inputId = "select", label = "Select Input"),
    verbatimTextOutput(outputId = "select")
  )
  server <- function(input, output, session) {

    observeEvent(input$text, {
      inputSweetAlert(
        session = session, inputId = "mytext", input = "text",
        title = "What's your name ?"
      )
    })
    output$text <- renderPrint(input$mytext)

    observeEvent(input$password, {
      inputSweetAlert(
        session = session, inputId = "mypassword", input = "password",
        title = "What's your password ?"
      )
    })
    output$password <- renderPrint(input$mypassword)

    observeEvent(input$radio, {
      inputSweetAlert(
        session = session, inputId = "myradio", input = "radio",
        inputOptions = c("Banana" , "Orange", "Apple"),
        title = "What's your favorite fruit ?"
      )
    })
    output$radio <- renderPrint(input$myradio)

    observeEvent(input$checkbox, {
      inputSweetAlert(
        session = session, inputId = "mycheckbox", input = "checkbox",
        inputPlaceholder = "Yes I agree",
        title = "Do you agree ?"
      )
    })
    output$checkbox <- renderPrint(input$mycheckbox)

    observeEvent(input$select, {
      inputSweetAlert(
        session = session, inputId = "myselect", input = "select",
        inputOptions = c("Banana" , "Orange", "Apple"),
        title = "What's your favorite fruit ?"
      )
    })
    output$select <- renderPrint(input$myselect)

  }

  shinyApp(ui = ui, server = server)
}

dreamRs/shinyWidgets documentation built on June 20, 2019, 7:36 a.m.