actionButton | R Documentation |
Creates an action button or link whose value is initially zero, and increments by one each time it is pressed.
actionButton( inputId, label, icon = NULL, width = NULL, ..., status = NULL, gradient = FALSE, outline = FALSE, size = NULL, flat = FALSE )
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:
|
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: |
flat |
Whether to apply a flat style. Default to FALSE. |
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.
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.
[observeEvent()] and [eventReactive()]
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.