buttonInput | R Documentation |
Button inputs are useful as triggers for reactive or observer expressions.
The reactive value of a button input begins as NULL
, but subsequently is
the number of clicks.
buttonInput(..., id, label, stretch = FALSE, download = FALSE, tooltip = NULL)
updateButtonInput(
id,
label = NULL,
value = NULL,
disable = NULL,
enable = NULL,
tooltip = NULL,
session = getDefaultReactiveDomain()
)
linkInput(..., id, label, stretch = FALSE, download = FALSE, tooltip = NULL)
updateLinkInput(
id,
label = NULL,
value = NULL,
enable = NULL,
disable = NULL,
tooltip = NULL,
session = getDefaultReactiveDomain()
)
tooltip(..., placement = "top", fade = TRUE)
... |
Additional named arguments passed as HTML attributes to the parent element. |
id |
A character string specifying the id of the reactive input. |
label |
A character string specifying the label text on the button or link input. |
stretch |
One of |
download |
One of |
tooltip |
A call to |
value |
A number specifying a new value for the button, defaults to
|
disable |
if |
enable |
If |
session |
A reactive context, defaults to |
placement |
One of |
fade |
One of |
To remove a button or link input's tooltip pass an empty tooltip,
tooltip()
, to updateButtonInput()
or updateLinkInput()
.
buttonInput( id = NULL, label = "Label" )
buttonInput( .style %>% background("primary"), id = NULL, label = "Label" )
Use the width()
utility to adjust the size of a button.
buttonInput( .style %>% background("danger") %>% width(75), # <- id = NULL, label = "Label" )
div( "Curabitur", linkInput(id = "link1", label = "vulputate"), "vestibulum lorem." )
Use a stretched button to make an entire card clickable.
card( .style %>% border("primary") %>% font("primary"), header = "Product summary", p("Here is a summary"), p("This is a second paragraph"), footer = list( buttonInput( .style %>% background("primary"), id = "seemore", label = "See more", stretch = TRUE ) ) )
Here is a summary
This is a second paragraph
Notice, when you hover over the card the mouse cursor changes and the button appears hovered. The card is now passing clicks on to the button. Clicking anywhere on the card will trigger a click on the button.
card( header = "Card with stretched button", p("Notice when you hover over the card, the button also detects ", "the hover."), buttonInput( .style %>% background("primary"), id = NULL, label = "Label", stretch = TRUE ) )
Notice when you hover over the card, the button also detects the hover.
Pair a download button input with shiny::downloadHandler()
.
buttonInput( download = TRUE, # <- id = NULL, label = "Download", tags$i(class = "fas fa-download") )
Other inputs:
buttonGroupInput()
,
checkbarInput()
,
checkboxInput()
,
chipInput()
,
fileInput()
,
formInput()
,
listGroupInput()
,
menuInput()
,
navInput()
,
radioInput()
,
radiobarInput()
,
rangeInput()
,
selectInput()
,
textInput()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.