Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

feat: added disabled prop to range-slider (#4953)

Joaquin Corominab44cac54a7ca
diff --git a/frontend/src/components/ui/range-slider.tsx b/frontend/src/components/ui/range-slider.tsx
index ab385aaf7a..843f718c40 100644
--- a/frontend/src/components/ui/range-slider.tsx
+++ b/frontend/src/components/ui/range-slider.tsx
@@ -28,6 +28,7 @@ const RangeSlider = React.forwardRef<
"relative flex touch-none select-none hover:cursor-pointer",
"data-[orientation=horizontal]:w-full data-[orientation=horizontal]:items-center",
"data-[orientation=vertical]:h-full data-[orientation=vertical]:justify-center",
+ "data-[disabled]:cursor-not-allowed",
className,
)}
{...props}
@@ -46,6 +47,7 @@ const RangeSlider = React.forwardRef<
"absolute bg-blue-500 dark:bg-primary",
"data-[orientation=horizontal]:h-full",
"data-[orientation=vertical]:w-full",
+ "data-[disabled]:opacity-50",
)}
/>
</SliderPrimitive.Track>
@@ -54,7 +56,7 @@ const RangeSlider = React.forwardRef<
<TooltipTrigger asChild={true}>
<SliderPrimitive.Thumb
data-testid="thumb"
- className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
+ className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
onFocus={openActions.setTrue}
onBlur={openActions.setFalse}
onMouseEnter={openActions.setTrue}
@@ -75,7 +77,7 @@ const RangeSlider = React.forwardRef<
<TooltipTrigger asChild={true}>
<SliderPrimitive.Thumb
data-testid="thumb"
- className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
+ className="block h-4 w-4 rounded-full shadow-xsSolid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
onFocus={openActions.setTrue}
onBlur={openActions.setFalse}
onMouseEnter={openActions.setTrue}
diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
index bf7052f0a9..88864076e0 100644
--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx
+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
@@ -21,6 +21,7 @@ interface Data {
orientation: "horizontal" | "vertical";
showValue: boolean;
fullWidth: boolean;
+ disabled?: boolean;
}
export class RangeSliderPlugin implements IPlugin<T, Data> {
@@ -37,6 +38,7 @@ export class RangeSliderPlugin implements IPlugin<T, Data> {
orientation: z.enum(["horizontal", "vertical"]).default("horizontal"),
showValue: z.boolean().default(false),
fullWidth: z.boolean().default(false),
+ disabled: z.boolean().optional(),
});
render(props: IPluginProps<T, Data>): JSX.Element {
@@ -76,6 +78,7 @@ const RangeSliderComponent = ({
orientation,
showValue,
fullWidth,
+ disabled,
valueMap,
}: RangeSliderProps): JSX.Element => {
const id = useId();
@@ -116,6 +119,7 @@ const RangeSliderComponent = ({
max={stop}
step={step}
orientation={orientation}
+ disabled={disabled}
// Triggered on all value changes
onValueChange={(nextValue: number[]) => {
setInternalValue(nextValue);
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index d93494e70d..4cca8e0f58 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -416,6 +416,7 @@ class range_slider(UIElement[list[Numeric], Sequence[Numeric]]):
label (str): Markdown label for the element.
on_change (Optional[Callable[[Sequence[Numeric]], None]]): Optional callback to run when this element's value changes.
full_width (bool): Whether the input should take up the full width of its container.
+ disabled (bool, optional): Whether the slider is disabled. Defaults to False.
Methods:
from_series(series: DataFrameSeries, **kwargs: Any) -> range_slider:
@@ -439,6 +440,7 @@ class range_slider(UIElement[list[Numeric], Sequence[Numeric]]):
label: str = "",
on_change: Optional[Callable[[Sequence[Numeric]], None]] = None,
full_width: bool = False,
+ disabled: bool = False,
) -> None:
self.start: Numeric
self.stop: Numeric
@@ -504,6 +506,7 @@ class range_slider(UIElement[list[Numeric], Sequence[Numeric]]):
"orientation": orientation,
"show-value": show_value,
"full-width": full_width,
+ "disabled": disabled,
},
on_change=on_change,
)
@@ -544,6 +547,7 @@ class range_slider(UIElement[list[Numeric], Sequence[Numeric]]):
"orientation": orientation,
"show-value": show_value,
"full-width": full_width,
+ "disabled": disabled,
},
on_change=on_change,
)