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 radio (#4985)

Joaquin Corominac90833febcd2
diff --git a/frontend/src/plugins/impl/RadioPlugin.tsx b/frontend/src/plugins/impl/RadioPlugin.tsx
index a36f7de1e3..660a3c1c59 100644
--- a/frontend/src/plugins/impl/RadioPlugin.tsx
+++ b/frontend/src/plugins/impl/RadioPlugin.tsx
@@ -18,6 +18,7 @@ interface Data {
label: string | null;
inline: boolean;
options: string[];
+ disabled?: boolean;
}
// The value is null when `initialValue` is null
@@ -31,6 +32,7 @@ export class RadioPlugin implements IPlugin<S, Data> {
inline: z.boolean().default(false),
label: z.string().nullable(),
options: z.array(z.string()),
+ disabled: z.boolean().optional(),
});
render(props: IPluginProps<S, Data>): JSX.Element {
@@ -56,6 +58,7 @@ export const Radio = (props: RadioProps): JSX.Element => {
onValueChange={props.setValue}
className={cn(props.inline && "grid-flow-col gap-4")}
aria-label="Radio Group"
+ disabled={props.disabled}
>
{props.options.map((option, i) => (
<div className="flex items-center space-x-2" key={i}>
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index bc1a5ce2bf..ba6138975d 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -664,6 +664,7 @@ class radio(UIElement[Optional[str], Any]):
label (str, optional): Optional markdown label for the element. Defaults to "".
on_change (Callable[[Any], None], optional): Optional callback to run when
this element's value changes. Defaults to None.
+ disabled (bool, optional): Whether the radio group is disabled. Defaults to False.
"""
_name: Final[str] = "marimo-radio"
@@ -676,6 +677,7 @@ class radio(UIElement[Optional[str], Any]):
*,
label: str = "",
on_change: Optional[Callable[[Any], None]] = None,
+ disabled: bool = False,
) -> None:
if not isinstance(options, dict):
if len(set(options)) != len(options):
@@ -689,6 +691,7 @@ class radio(UIElement[Optional[str], Any]):
args={
"options": list(options.keys()),
"inline": inline,
+ "disabled": disabled,
},
on_change=on_change,
)