Debian Codegraph @

man/actionButton.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/input-action.R
3 \name{actionButton}
4 \alias{actionButton}
5 \alias{actionLink}
6 \title{Action button/link}
7 \usage{
8 actionButton(inputId, label, icon = NULL, width = NULL, disabled = FALSE, ...)
9
10 actionLink(inputId, label, icon = NULL, ...)
11 }
12 \arguments{
13 \item{inputId}{The \code{input} slot that will be used to access the value.}
14
15 \item{label}{The contents of the button or link--usually a text label, but
16 you could also use any other HTML, like an image.}
17
18 \item{icon}{An optional \code{\link[=icon]{icon()}} to appear on the button.}
19
20 \item{width}{The width of the input, e.g. \code{'400px'}, or \code{'100\%'};
21 see \code{\link[=validateCssUnit]{validateCssUnit()}}.}
22
23 \item{disabled}{If \code{TRUE}, the button will not be clickable. Use
24 \code{\link[=updateActionButton]{updateActionButton()}} to dynamically enable/disable the button.}
25
26 \item{...}{Named attributes to be applied to the button or link.}
27 }
28 \description{
29 Creates an action button or link whose value is initially zero, and increments by one
30 each time it is pressed.
31 }
32 \section{Server value}{
33
34 An integer of class \code{"shinyActionButtonValue"}. This class differs from
35 ordinary integers in that a value of 0 is considered "falsy".
36 This implies two things:
37 \itemize{
38 \item Event handlers (e.g., \code{\link[=observeEvent]{observeEvent()}}, \code{\link[=eventReactive]{eventReactive()}}) won't execute on initial load.
39 \item Input validation (e.g., \code{\link[=req]{req()}}, \code{\link[=need]{need()}}) will fail on initial load.
40 }
41 }
42
43 \examples{
44 ## Only run examples in interactive R sessions
45 if (interactive()) {
46
47 ui <- fluidPage(
48 sliderInput("obs", "Number of observations", 0, 1000, 500),
49 actionButton("goButton", "Go!", class = "btn-success"),
50 plotOutput("distPlot")
51 )
52
53 server <- function(input, output) {
54 output$distPlot <- renderPlot({
55 # Take a dependency on input$goButton. This will run once initially,
56 # because the value changes from NULL to 0.
57 input$goButton
58
59 # Use isolate() to avoid dependency on input$obs
60 dist <- isolate(rnorm(input$obs))
61 hist(dist)
62 })
63 }
64
65 shinyApp(ui, server)
66
67 }
68
69 ## Example of adding extra class values
70 actionButton("largeButton", "Large Primary Button", class = "btn-primary btn-lg")
71 actionLink("infoLink", "Information Link", class = "btn-info")
72
73 }
74 \seealso{
75 \code{\link[=observeEvent]{observeEvent()}} and \code{\link[=eventReactive]{eventReactive()}}
76
77 Other input elements:
78 \code{\link{checkboxGroupInput}()},
79 \code{\link{checkboxInput}()},
80 \code{\link{dateInput}()},
81 \code{\link{dateRangeInput}()},
82 \code{\link{fileInput}()},
83 \code{\link{numericInput}()},
84 \code{\link{passwordInput}()},
85 \code{\link{radioButtons}()},
86 \code{\link{selectInput}()},
87 \code{\link{sliderInput}()},
88 \code{\link{submitButton}()},
89 \code{\link{textAreaInput}()},
90 \code{\link{textInput}()},
91 \code{\link{varSelectInput}()}
92 }
93 \concept{input elements}