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.

improvement: Add rows prop to TextAreaMultiSelect component (#405)

Myles Scolnick81bceeeb2ce5
diff --git a/frontend/src/components/forms/switchable-multi-select.tsx b/frontend/src/components/forms/switchable-multi-select.tsx
index 9bc4363a74..4de6e2110b 100644
--- a/frontend/src/components/forms/switchable-multi-select.tsx
+++ b/frontend/src/components/forms/switchable-multi-select.tsx
@@ -104,6 +104,7 @@ export const TextAreaMultiSelect: React.FC<{
<Textarea
value={valueAsArray.join(DELIMINATOR)}
className={className}
+ rows={4}
onChange={(e) => {
if (e.target.value === "") {
onChange([]);
diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsx
index 9e5c66cf26..136928239c 100644
--- a/frontend/src/components/ui/textarea.tsx
+++ b/frontend/src/components/ui/textarea.tsx
@@ -16,7 +16,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
<textarea
className={cn(
"shadow-xsSolid hover:shadow-smSolid disabled:shadow-xsSolid focus-visible:shadow-mdSolid",
- "flex h-20 w-full mb-1 rounded-sm border border-input bg-transparent px-3 py-2 text-sm font-code ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:border-accent disabled:cursor-not-allowed disabled:opacity-50 min-h-[1.5rem]",
+ "flex w-full mb-1 rounded-sm border border-input bg-transparent px-3 py-2 text-sm font-code ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:border-accent disabled:cursor-not-allowed disabled:opacity-50 min-h-[1.5rem]",
className
)}
onClick={Events.stopPropagation()}
diff --git a/frontend/src/plugins/impl/TextAreaPlugin.tsx b/frontend/src/plugins/impl/TextAreaPlugin.tsx
index 2c1355cc80..0e656ca4e0 100644
--- a/frontend/src/plugins/impl/TextAreaPlugin.tsx
+++ b/frontend/src/plugins/impl/TextAreaPlugin.tsx
@@ -14,6 +14,7 @@ interface Data {
maxLength?: number;
minLength?: number;
disabled?: boolean;
+ rows: number;
fullWidth: boolean;
}
@@ -27,6 +28,7 @@ export class TextAreaPlugin implements IPlugin<T, Data> {
maxLength: z.number().optional(),
minLength: z.number().optional(),
disabled: z.boolean().optional(),
+ rows: z.number().default(4),
fullWidth: z.boolean().default(false),
});
@@ -59,7 +61,7 @@ const TextAreaComponent = (props: TextAreaComponentProps) => {
className={cn("font-code", {
"w-full": props.fullWidth,
})}
- rows={5}
+ rows={props.rows}
cols={33}
maxLength={props.maxLength}
minLength={props.minLength}
diff --git a/marimo/_plugins/ui/_impl/input.py b/marimo/_plugins/ui/_impl/input.py
index 71c07a1d57..addcc1906b 100644
--- a/marimo/_plugins/ui/_impl/input.py
+++ b/marimo/_plugins/ui/_impl/input.py
@@ -390,6 +390,7 @@ class text_area(UIElement[str, str]):
- `placeholder`: placeholder text to display when the text area is empty
- `max_length`: maximum length of input
- `disabled`: whether the input is disabled
+ - `rows`: number of rows of text to display
- `label`: text label for the element
- `on_change`: optional callback to run when this element's value changes
- `full_width`: whether the input should take up the full width of its
@@ -404,6 +405,7 @@ class text_area(UIElement[str, str]):
placeholder: str = "",
max_length: Optional[int] = None,
disabled: bool = False,
+ rows: Optional[int] = None,
*,
label: str = "",
on_change: Optional[Callable[[str], None]] = None,
@@ -418,6 +420,7 @@ class text_area(UIElement[str, str]):
"max-length": max_length,
"disabled": disabled,
"full-width": full_width,
+ "rows": rows,
},
on_change=on_change,
)