-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathupdatePrettyRadioButtons.R
70 lines (61 loc) · 1.55 KB
/
updatePrettyRadioButtons.R
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
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h1("Update pretty radio buttons"),
br(),
fluidRow(
column(
width = 6,
prettyRadioButtons(
inputId = "radio1",
label = "Update my value!",
choices = month.name[1:4],
status = "danger",
icon = icon("xmark")
),
verbatimTextOutput(outputId = "res1"),
br(),
radioButtons(
inputId = "update1", label = "Update value :",
choices = month.name[1:4], inline = TRUE
)
),
column(
width = 6,
prettyRadioButtons(
inputId = "radio2",
label = "Update my choices!",
thick = TRUE,
choices = month.name[1:4],
animation = "pulse",
status = "info"
),
verbatimTextOutput(outputId = "res2"),
br(),
actionButton(inputId = "update2", label = "Update choices !")
)
)
)
server <- function(input, output, session) {
output$res1 <- renderPrint(input$radio1)
observeEvent(input$update1, {
updatePrettyRadioButtons(
session = session,
inputId = "radio1",
selected = input$update1
)
}, ignoreNULL = FALSE)
output$res2 <- renderPrint(input$radio2)
observeEvent(input$update2, {
updatePrettyRadioButtons(
session = session,
inputId = "radio2",
choices = sample(month.name, 4),
prettyOptions = list(animation = "pulse",
status = "info",
shape = "round")
)
}, ignoreInit = TRUE)
}
if (interactive())
shinyApp(ui, server)