Skip to content

Commit 1285798

Browse files
committed
Add back spinner selector option
1 parent b822ee1 commit 1285798

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

shiny/ui/busy_indicators.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def options(
1616
spinner_color: str | None = None,
1717
spinner_size: str | None = None,
1818
spinner_delay: str | None = None,
19+
spinner_selector: str | None = None,
1920
pulse_background: str | None = None,
2021
pulse_height: str | None = None,
2122
pulse_speed: str | None = None,
@@ -36,6 +37,10 @@ def options(
3637
The amount of time to wait before showing the spinner. This can be any valid
3738
CSS time and can useful for not showing the spinner if the computation
3839
finishes quickly.
40+
spinner_selector
41+
A CSS selector for scoping the spinner customization.
42+
This can be useful if you want to have different spinners for different
43+
parts of the app. Defaults to the root document element.
3944
pulse_background
4045
A CCS background definition for the pulse. The default uses a
4146
[linear-gradient](https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient)
@@ -55,6 +60,7 @@ def options(
5560
color=spinner_color,
5661
size=spinner_size,
5762
delay=spinner_delay,
63+
selector=spinner_selector,
5864
),
5965
pulse_options(
6066
background=pulse_background,
@@ -69,8 +75,9 @@ def spinner_options(
6975
color: str | None = None,
7076
size: str | None = None,
7177
delay: str | None = None,
78+
selector: str | None = None,
7279
) -> TagChild:
73-
if color is None and size is None and delay is None:
80+
if color is None and size is None and delay is None and selector is None:
7481
return None
7582

7683
css_vars = (
@@ -79,7 +86,10 @@ def spinner_options(
7986
+ (f"--shiny-spinner-delay: {delay};" if delay else "")
8087
)
8188

82-
return tags.style(":root {" + css_vars + "}")
89+
if selector is None:
90+
selector = ":root"
91+
92+
return tags.style(f"{selector} {{ {css_vars} }}")
8393

8494

8595
def pulse_options(

0 commit comments

Comments
 (0)