Skip to content

Commit d5c8a0c

Browse files
committed
docs: Explicitly call out module usage in bookmark button
1 parent 5cb608f commit d5c8a0c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

shiny/bookmark/_button.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ def input_bookmark_button(
2828
2929
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.
3030
31+
Default behavior
32+
----------------
33+
34+
By default, Shiny will listen for the default `id` being used and call
35+
`session.bookmark()` on button click. However, this will not work if the bookmark
36+
button is used within a module or more than one bookmark button is being utilized.
37+
38+
For both situations, a custom `id` value is required.
39+
40+
There are two recommendations to maintain the expected bookmark behavior:
41+
* The supplied `id` value should be excluded from bookmarking with
42+
`session.bookmark.exclude.append(ID)`.
43+
* A reactive effect should be added that performs the bookmarking
44+
(`session.bookmark()`) when the button is pressed.
45+
46+
```python
47+
session.bookmark.exclude.append("CUSTOM_ID")
48+
49+
@reactive.effect
50+
@reactive.event(input.CUSTOM_ID)
51+
async def _():
52+
await session.bookmark()
53+
```
54+
3155
Parameters
3256
----------
3357
label
@@ -39,7 +63,7 @@ def input_bookmark_button(
3963
disabled
4064
Whether the button is disabled.
4165
id
42-
An ID for the bookmark button. The only time it is necessary to set the ID unless you have more than one bookmark button in your application. If you specify an input ID, it should be excluded from bookmarking with `session.bookmark.exclude.append(ID)`, and you must create a reactive effect that performs the bookmarking (`session.bookmark()`) when the button is pressed.
66+
An ID for the bookmark button.
4367
title
4468
A tooltip that is shown when the mouse cursor hovers over the button.
4569
kwargs

0 commit comments

Comments
 (0)