ui.input_bookmark_button
ui.input_bookmark_button(
label='Bookmark...',
*,
icon=MISSING,
width=None,
disabled=False,
id=BOOKMARK_ID,
title="Bookmark this application's state and get a URL for sharing.",
**kwargs,
)Button for bookmarking/sharing.
A bookmarkButton is a [input_action_button()] with a default label that consists of a link icon and the text "Bookmark…". It is meant to be used for bookmarking state.
Parameters
label : TagChild = 'Bookmark…'-
The button label.
icon : TagChild | MISSING_TYPE = MISSING-
The icon to display on the button.
width : Optional[str] = None-
The CSS width, e.g. ‘400px’, or ‘100%’.
disabled : bool = False-
Whether the button is disabled.
id : str = BOOKMARK_ID-
An ID for the bookmark button. This should only be provided when multiple buttons are needed (or used inside a module). See the note on multiple buttons.
title : str = "Bookmark this application's state and get a URL for sharing."-
A tooltip that is shown when the mouse cursor hovers over the button.
kwargs : TagAttrValue = {}-
Additional attributes for the button.
Returns
: Tag-
A UI element.
See Also
Examples
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from starlette.requests import Request
from shiny import App, Inputs, Outputs, Session, ui
# App UI **must** be a function to ensure that each user restores their own UI values.
def app_ui(request: Request):
return ui.page_fluid(
ui.markdown(
"Directions: "
"\n1. Change the radio button selection below"
"\n2. Save the bookmark."
"\n3. Then, refresh your browser page to see the radio button selection has been restored."
),
ui.hr(),
ui.input_radio_buttons("letter", "Choose a letter", choices=["A", "B", "C"]),
ui.input_bookmark_button(label="Save bookmark!"),
)
def server(input: Inputs, output: Outputs, session: Session):
# @reactive.effect
# @reactive.event(input.letter, ignore_init=True)
# async def _():
# await session.bookmark()
@session.bookmark.on_bookmarked
async def _(url: str):
await session.bookmark.update_query_string(url)
app = App(app_ui, server, bookmark_store="url")