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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
feat: added disabled prop to slider (#4890)
Joaquin Corominaae9156b7b284
diff --git a/frontend/src/components/ui/slider.tsx b/frontend/src/components/ui/slider.tsxindex c602edc887..fe1d1ba6e3 100644--- a/frontend/src/components/ui/slider.tsx+++ b/frontend/src/components/ui/slider.tsx@@ -28,6 +28,7 @@ const Slider = 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 Slider = 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 Slider = React.forwardRef<<TooltipTrigger asChild={true}><SliderPrimitive.Thumbdata-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/SliderPlugin.tsx b/frontend/src/plugins/impl/SliderPlugin.tsxindex 9f9a4811eb..f0752d4983 100644--- a/frontend/src/plugins/impl/SliderPlugin.tsx+++ b/frontend/src/plugins/impl/SliderPlugin.tsx@@ -22,6 +22,7 @@ interface Data {showValue: boolean;fullWidth: boolean;includeInput: boolean;+ disabled?: boolean;}export class SliderPlugin implements IPlugin<T, Data> {@@ -39,6 +40,7 @@ export class SliderPlugin implements IPlugin<T, Data> {showValue: z.boolean().default(false),fullWidth: z.boolean().default(false),includeInput: z.boolean().default(false),+ disabled: z.boolean().optional(),});render(props: IPluginProps<T, Data>): JSX.Element {@@ -81,6 +83,7 @@ const SliderComponent = ({fullWidth,valueMap,includeInput,+ disabled,}: SliderProps): JSX.Element => {const id = useId();@@ -132,6 +135,7 @@ const SliderComponent = ({}}}valueMap={valueMap} // Pass valueMap to Slider+ disabled={disabled}/>{showValue && (<div className="text-xs text-muted-foreground min-w-[16px]">@@ -152,6 +156,7 @@ const SliderComponent = ({step={step}className="w-24"aria-label={`${label || "Slider"} value input`}+ isDisabled={disabled}/>)}</div>diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.pyindex c7a791e2ed..c4037cdb78 100644--- a/marimo/_plugins/ui/_impl/input.py+++ b/marimo/_plugins/ui/_impl/input.py@@ -185,6 +185,7 @@ class slider(UIElement[Numeric, Numeric]):value (Optional[Numeric]): Default value.debounce (bool): Whether to debounce the slider to only send the valueon mouse-up or drag-end. Defaults to False.+ disabled (bool, optional): Whether the slider is disabled. Defaults to False.orientation (Literal["horizontal", "vertical"]): The orientation of theslider, either "horizontal" or "vertical". Defaults to "horizontal".show_value (bool): Whether to display the current value of the slider.@@ -222,6 +223,7 @@ class slider(UIElement[Numeric, Numeric]):step: Optional[Numeric] = None,value: Optional[Numeric] = None,debounce: bool = False,+ disabled: bool = False,orientation: Literal["horizontal", "vertical"] = "horizontal",show_value: bool = False,include_input: bool = False,@@ -293,6 +295,7 @@ class slider(UIElement[Numeric, Numeric]):"step": 1,"steps": steps,"debounce": debounce,+ "disabled": disabled,"orientation": orientation,"show-value": show_value,"include-input": include_input,@@ -335,6 +338,7 @@ class slider(UIElement[Numeric, Numeric]):"step": step if step is not None else None,"steps": [],"debounce": debounce,+ "disabled": disabled,"orientation": orientation,"show-value": show_value,"include-input": include_input,diff --git a/tests/_server/export/snapshots/notebook_with_outputs.ipynb.txt b/tests/_server/export/snapshots/notebook_with_outputs.ipynb.txtindex b89012b614..725dfc2d36 100644--- a/tests/_server/export/snapshots/notebook_with_outputs.ipynb.txt+++ b/tests/_server/export/snapshots/notebook_with_outputs.ipynb.txt@@ -139,7 +139,7 @@{"data": {"text/markdown": [- "<marimo-slider data-initial-value='0' data-label='null' data-start='0' data-stop='10' data-steps='[]' data-debounce='false' data-orientation='&quot;horizontal&quot;' data-show-value='false' data-include-input='false' data-full-width='false'></marimo-slider>"+ "<marimo-slider data-initial-value='0' data-label='null' data-start='0' data-stop='10' data-steps='[]' data-debounce='false' data-disabled='false' data-orientation='&quot;horizontal&quot;' data-show-value='false' data-include-input='false' data-full-width='false'></marimo-slider>"]},"metadata": {},