tingle-modal: Tingle modal

Description Usage Arguments Examples

Description

An alternative modal window. Load dependencies in UI with load_tingle, use tingle_* in server.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
load_tingle()

tingle_show(ui, close_id = NULL, session = getDefaultReactiveDomain())

tingle_dialog(..., footer = tingle_button(), easy_close = TRUE,
  sticky_footer = FALSE, css_class = NULL)

tingle_button(label = "Close", status = "default", pull_right = TRUE)

tingle_remove(session = getDefaultReactiveDomain())

Arguments

ui

Content of the modal defined with tingle_dialog.

close_id

Optionnal inputId to retrieve server-side when modal is closed by user.

session

The session object passed to function given to shinyServer.

...

UI elements for the body of the modal dialog box.

footer

UI for footer. Use NULL for no footer.

easy_close

If TRUE, the modal dialog can be dismissed by clicking outside the dialog box, or be pressing the Escape key, or by clicking the close button.

sticky_footer

Set to TRUE for a footer always visible on screen.

css_class

Custom CSS classes that will be added to tingle container.

label

The contents of the button or link–usually a text label, but you could also use any other HTML, like an image.

status

Status for the button: "default" (default), "primary" or "danger".

pull_right

Align the button on the right.

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

  ui <- fluidPage(

    load_tingle(),

    tags$h1("Examples tingle modal"),

    actionButton(inputId = "launch1", label = "Open modal"),
    actionButton(inputId = "launch2", label = "Another one")
  )

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


    output$plot <- renderPlot({
      req(input$n)
      hist(rnorm(input$n))
    })

    observeEvent(input$launch1, {
      tingle_show(tingle_dialog(
        tags$h2("Yes! A modal!"),
        plotOutput(outputId = "plot"),
        sliderInput(
          inputId = "n", label = "Number of observations",
          min = 10, max = 200, value = 20, width = "100%"
        )
      ))
    })

    observeEvent(input$launch2, {
      tingle_show(tingle_dialog(
        tags$h2("Very important!"),
        tags$p("Do you like Shiny?"),
        footer = tagList(
          actionButton("ofcourse", "Of course!", width = "49%"),
          actionButton("yes", "Yes!", width = "49%")
        ),
        easy_close = FALSE
      ))
    })

    observe({
      input$ofcourse
      input$yes
      tingle_remove()
    })

  }

  shinyApp(ui, server)
}

ardata-fr/shinytools documentation built on Nov. 15, 2019, 7:53 p.m.