| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/bookmark-state.R |
| 3 |
\name{bookmarkButton} |
| 4 |
\alias{bookmarkButton} |
| 5 |
\title{Create a button for bookmarking/sharing} |
| 6 |
\usage{ |
| 7 |
bookmarkButton( |
| 8 |
label = "Bookmark...", |
| 9 |
icon = shiny::icon("link", lib = "glyphicon"), |
| 10 |
title = "Bookmark this application's state and get a URL for sharing.", |
| 11 |
..., |
| 12 |
id = "._bookmark_" |
| 13 |
) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{label}{The contents of the button or link--usually a text label, but |
| 17 |
you could also use any other HTML, like an image.} |
| 18 |
|
| 19 |
\item{icon}{An optional \code{\link[=icon]{icon()}} to appear on the button.} |
| 20 |
|
| 21 |
\item{title}{A tooltip that is shown when the mouse cursor hovers over the |
| 22 |
button.} |
| 23 |
|
| 24 |
\item{...}{Named attributes to be applied to the button or link.} |
| 25 |
|
| 26 |
\item{id}{An ID for the bookmark button. The only time it is necessary to set |
| 27 |
the ID unless you have more than one bookmark button in your application. |
| 28 |
If you specify an input ID, it should be excluded from bookmarking with |
| 29 |
\code{\link[=setBookmarkExclude]{setBookmarkExclude()}}, and you must create an observer that |
| 30 |
does the bookmarking when the button is pressed. See the examples below.} |
| 31 |
} |
| 32 |
\description{ |
| 33 |
A \code{bookmarkButton} is a \code{\link[=actionButton]{actionButton()}} with a default label |
| 34 |
that consists of a link icon and the text "Bookmark...". It is meant to be |
| 35 |
used for bookmarking state. |
| 36 |
} |
| 37 |
\examples{ |
| 38 |
## Only run these examples in interactive sessions |
| 39 |
if (interactive()) { |
| 40 |
|
| 41 |
# This example shows how to use multiple bookmark buttons. If you only need |
| 42 |
# a single bookmark button, see examples in ?enableBookmarking. |
| 43 |
ui <- function(request) { |
| 44 |
fluidPage( |
| 45 |
tabsetPanel(id = "tabs", |
| 46 |
tabPanel("One", |
| 47 |
checkboxInput("chk1", "Checkbox 1"), |
| 48 |
bookmarkButton(id = "bookmark1") |
| 49 |
), |
| 50 |
tabPanel("Two", |
| 51 |
checkboxInput("chk2", "Checkbox 2"), |
| 52 |
bookmarkButton(id = "bookmark2") |
| 53 |
) |
| 54 |
) |
| 55 |
) |
| 56 |
} |
| 57 |
server <- function(input, output, session) { |
| 58 |
# Need to exclude the buttons from themselves being bookmarked |
| 59 |
setBookmarkExclude(c("bookmark1", "bookmark2")) |
| 60 |
|
| 61 |
# Trigger bookmarking with either button |
| 62 |
observeEvent(input$bookmark1, { |
| 63 |
session$doBookmark() |
| 64 |
}) |
| 65 |
observeEvent(input$bookmark2, { |
| 66 |
session$doBookmark() |
| 67 |
}) |
| 68 |
} |
| 69 |
enableBookmarking(store = "url") |
| 70 |
shinyApp(ui, server) |
| 71 |
} |
| 72 |
} |
| 73 |
\seealso{ |
| 74 |
\code{\link[=enableBookmarking]{enableBookmarking()}} for more examples. |
| 75 |
} |