actionButton: Bootstrap 4 Action button/link

Description Usage Arguments Server value Note See Also Examples

View source: R/inputs.R

Description

Creates an action button or link whose value is initially zero, and increments by one each time it is pressed.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
actionButton(
  inputId,
  label,
  icon = NULL,
  width = NULL,
  ...,
  status = NULL,
  gradient = FALSE,
  outline = FALSE,
  size = NULL,
  flat = FALSE
)

Arguments

inputId

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

label

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

icon

An optional [icon()] to appear on the button.

width

The width of the input, e.g. ''400px'‘, or '’100 see [validateCssUnit()].

...

Named attributes to be applied to the button or link.

status

Button status color. Valid statuses are defined as follows:

  • primary: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#007bff")}.

  • secondary: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#6c757d")}.

  • info: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#17a2b8")}.

  • success: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#28a745")}.

  • warning: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#ffc107")}.

  • danger: \Sexpr[results=rd, stage=render]{bs4Dash:::rd_color_tag("#dc3545")}.

gradient

Whether to apply gradient to color. Default to FALSE.

outline

Whether to display an outline style. Status must not be NULL if TRUE. Default to FALSE.

size

Button size. Default to NULL. Possible choices: c("lg", "sm", "xs").

flat

Whether to apply a flat style. Default to FALSE.

Server value

An integer of class '"shinyActionButtonValue"'. This class differs from ordinary integers in that a value of 0 is considered "falsy". This implies two things: * Event handlers (e.g., [observeEvent()], [eventReactive()]) won't execute on initial load. * Input validation (e.g., [req()], [need()]) will fail on initial load.

Note

One may also pass the status directly via the ... parameter using class = "btn-primary", for the primary status for instance. Same thing for other styles like the size.

See Also

[observeEvent()] and [eventReactive()]

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
## Only run examples in interactive R sessions
if (interactive()) {
 library(shiny)
 library(bs4Dash)

 shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(
      title = bs4DashBrand(
        title = "My dashboard",
        color = "primary",
        src = "https://adminlte.io/themes/v3",
        image = "https://adminlte.io/themes/v3/dist/img/AdminLTELogo.png"
      )
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      sliderInput("obs", "Number of observations", 0, 1000, 500),
      actionButton(
       "goButton", "Go!", 
       status = "danger", 
       outline = TRUE, 
       flat = TRUE, 
       size = "lg"
      ),
     plotOutput("distPlot")
    ),
    controlbar = dashboardControlbar(),
    title = "DashboardPage"
  ),
  server = function(input, output) {
   output$distPlot <- renderPlot({
    # Take a dependency on input$goButton. This will run once initially,
    # because the value changes from NULL to 0.
    input$goButton

    # Use isolate() to avoid dependency on input$obs
    dist <- isolate(rnorm(input$obs))
    hist(dist)
   })
  }
 )

}

## Example of adding extra class values
actionButton("largeButton", "Large Primary Button", class = "btn-primary btn-lg")

bs4Dash documentation built on July 23, 2021, 5:06 p.m.