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
fix: button stretch in vstack (#4545)
Myles Scolnick5e8058247f62
diff --git a/frontend/src/plugins/impl/ButtonPlugin.tsx b/frontend/src/plugins/impl/ButtonPlugin.tsxindex 1dd92b093d..7d8293ad12 100644--- a/frontend/src/plugins/impl/ButtonPlugin.tsx+++ b/frontend/src/plugins/impl/ButtonPlugin.tsx@@ -44,6 +44,7 @@ export class ButtonPlugin implements IPlugin<number, Data> {keyboardShortcut={keyboardShortcut}className={cn({"w-full": fullWidth,+ "w-fit": !fullWidth,})}onClick={(evt) => {if (disabled) {diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsxindex c814c386ea..bf7052f0a9 100644--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx@@ -93,6 +93,7 @@ const RangeSliderComponent = ({label={label}id={id}align={orientation === "horizontal" ? "left" : "top"}+ className={cn(fullWidth && "my-1 w-full")}fullWidth={fullWidth}><div@@ -100,6 +101,7 @@ const RangeSliderComponent = ({"flex items-center gap-2",orientation === "vertical" &&"items-end inline-flex justify-center self-center mx-2",+ fullWidth && "w-full",)}><RangeSlider@@ -153,9 +155,5 @@ const RangeSliderComponent = ({</Labeled>);- return fullWidth ? (- <div className="my-3">{sliderElement}</div>- ) : (- sliderElement- );+ return sliderElement;};diff --git a/frontend/src/plugins/impl/SliderPlugin.tsx b/frontend/src/plugins/impl/SliderPlugin.tsxindex 7a6a0b28cc..4baa2b9202 100644--- a/frontend/src/plugins/impl/SliderPlugin.tsx+++ b/frontend/src/plugins/impl/SliderPlugin.tsx@@ -93,6 +93,7 @@ const SliderComponent = ({id={id}align={orientation === "horizontal" ? "left" : "top"}fullWidth={fullWidth}+ className={cn(fullWidth && "my-1 w-full")}><divclassName={cn(@@ -137,9 +138,5 @@ const SliderComponent = ({</Labeled>);- return fullWidth ? (- <div className="my-3">{sliderElement}</div>- ) : (- sliderElement- );+ return sliderElement;};diff --git a/frontend/src/plugins/impl/common/labeled.tsx b/frontend/src/plugins/impl/common/labeled.tsxindex 09b4195da3..854130e5e0 100644--- a/frontend/src/plugins/impl/common/labeled.tsx+++ b/frontend/src/plugins/impl/common/labeled.tsx@@ -36,7 +36,7 @@ export const Labeled: React.FC<PropsWithChildren<Props>> = ({if (!label) {// If its a top label, just return the childrenif (align === "top") {- return children;+ return <div className={className}>{children}</div>;}// Otherwise, return the children in an inline-flex containerreturn <div className={cn("inline-flex", className)}>{children}</div>;diff --git a/marimo/_smoke_tests/issues/4544_flex.py b/marimo/_smoke_tests/issues/4544_flex.pynew file mode 100644index 0000000000..4249488d9f--- /dev/null+++ b/marimo/_smoke_tests/issues/4544_flex.py@@ -0,0 +1,122 @@+++import marimo++__generated_with = "0.12.9"+app = marimo.App(width="medium")++def _():+ import marimo as mo+ return (mo,)++[email protected](hide_code=True)+def _(mo):+ mo.md(r"""## Buttons""")+ return+++def _(mo):+ full_width = mo.ui.checkbox(label="Full width")+ full_width+ return (full_width,)+++def _(full_width, mo):+ items = [+ mo.ui.button(label="button", full_width=full_width.value),+ mo.ui.text(label="button"),+ ]+ return (items,)+++def _(items, mo):+ mo.vstack(items)+ return+++def _(items, mo):+ mo.hstack(items)+ return+++def _(items, mo):+ different_height_items = [+ *items,+ mo.ui.text_area(label="button"),+ ]+ return (different_height_items,)+++def _(different_height_items, mo):+ mo.vstack(different_height_items)+ return+++def _(different_height_items, mo):+ mo.hstack(different_height_items)+ return++[email protected](hide_code=True)+def _(mo):+ mo.md(r"""## Sliders""")+ return++[email protected](hide_code=True)+def _(full_width):+ full_width+ return+++def _(full_width, mo):+ range_slider = mo.ui.range_slider(+ start=1, stop=10, step=2, value=[2, 6], full_width=full_width.value+ )+ range_slider+ return (range_slider,)+++def _(mo, range_slider):+ mo.hstack([range_slider])+ return+++def _(mo, range_slider):+ mo.vstack([range_slider])+ return+++def _(full_width, mo):+ slider = mo.ui.slider(start=1, stop=10, step=2, full_width=full_width.value)+ slider+ return (slider,)+++def _(mo, slider):+ mo.hstack([slider])+ return+++def _(mo, slider):+ mo.vstack([slider])+ return+++if __name__ == "__main__":+ app.run()