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 date-picker (#5003)

Joaquin Coromina3de40e5226a5
diff --git a/frontend/src/plugins/impl/DatePickerPlugin.tsx b/frontend/src/plugins/impl/DatePickerPlugin.tsx
index 622967eb2d..d19e6d05ed 100644
--- a/frontend/src/plugins/impl/DatePickerPlugin.tsx
+++ b/frontend/src/plugins/impl/DatePickerPlugin.tsx
@@ -14,6 +14,7 @@ interface Data {
stop: string;
step?: string;
fullWidth: boolean;
+ disabled?: boolean;
}
export class DatePickerPlugin implements IPlugin<T, Data> {
@@ -26,6 +27,7 @@ export class DatePickerPlugin implements IPlugin<T, Data> {
stop: z.string(),
step: z.string().optional(),
fullWidth: z.boolean().default(false),
+ disabled: z.boolean().optional(),
});
render(props: IPluginProps<T, Data>): JSX.Element {
@@ -34,6 +36,7 @@ export class DatePickerPlugin implements IPlugin<T, Data> {
{...props.data}
value={props.value}
setValue={props.setValue}
+ disabled={props.data.disabled}
/>
);
}
@@ -63,6 +66,7 @@ const DatePickerComponent = (props: DatePickerProps): JSX.Element => {
aria-label={props.label ?? "date picker"}
minValue={parseDate(props.start)}
maxValue={parseDate(props.stop)}
+ isDisabled={props.disabled}
/>
</Labeled>
);
diff --git a/marimo/_plugins/ui/_impl/dates.py b/marimo/_plugins/ui/_impl/dates.py
index cfc5ee5abd..35ffbbbbce 100644
--- a/marimo/_plugins/ui/_impl/dates.py
+++ b/marimo/_plugins/ui/_impl/dates.py
@@ -70,6 +70,7 @@ class date(UIElement[str, dt.date]):
label (str, optional): Markdown label for the element.
on_change (Callable[[datetime.date], None], optional): Optional callback to run when this element's value changes.
full_width (bool, optional): Whether the input should take up the full width of its container.
+ disabled (bool, optional): Whether the input should be disabled.
"""
_name: Final[str] = "marimo-date"
@@ -85,6 +86,7 @@ class date(UIElement[str, dt.date]):
label: str = "",
on_change: Optional[Callable[[dt.date], None]] = None,
full_width: bool = False,
+ disabled: bool = False,
) -> None:
if isinstance(start, str):
start = self._convert_value(start)
@@ -125,6 +127,7 @@ class date(UIElement[str, dt.date]):
"start": self._start.isoformat(),
"stop": self._stop.isoformat(),
"full-width": full_width,
+ "disabled": disabled,
},
on_change=on_change,
)