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
break: markdown width clamped for more readable typography (#4551)
Myles Scolnick5a2c7804cd7b
diff --git a/docs/_static/example-thumbs/Screenshot 2025-04-15 at 8.15.03 AM.png b/docs/_static/example-thumbs/Screenshot 2025-04-15 at 8.15.03 AM.pngdeleted file mode 100644index a620e5fb73..0000000000Binary files a/docs/_static/example-thumbs/Screenshot 2025-04-15 at 8.15.03 AM.png and /dev/null differdiff --git a/docs/guides/configuration/theming.md b/docs/guides/configuration/theming.mdindex 297d7c2c3c..2f46cb4fcf 100644--- a/docs/guides/configuration/theming.md+++ b/docs/guides/configuration/theming.md@@ -8,6 +8,15 @@ To include a custom CSS file, in the configuration dropdown, add the relative fiapp = marimo.App(css_file="custom.css")```+## Theming at the project level++You may also set the `custom_css` field in your project configuration to apply a custom CSS file. This theme won't be applied if the notebook is shared with someone else, but it will be applied to all notebooks open inside the project.++```toml title="pyproject.toml"+[tool.marimo.display]+custom_css = ["additional.css"]+```+## CSS VariablesWe support only a few CSS variables as part of the "public API" for theming. These are:@@ -64,12 +73,12 @@ You can target a cell's styles from the `data-cell-name` attribute. You can also```css/* Target the cell named "My Cell" */-[data-cell-name="my_cell"] {+[data-cell-name='my_cell'] {background-color: light-dark(navy, pink);}/* Target the output of the cell named "My Cell" */-[data-cell-name="my_cell"] [data-cell-role="output"] {+[data-cell-name='my_cell'] [data-cell-role='output'] {background-color: light-dark(navy, pink);}```diff --git a/frontend/src/components/editor/output/Outputs.css b/frontend/src/components/editor/output/Outputs.cssindex 2a18a3d4dd..e8215b471d 100644--- a/frontend/src/components/editor/output/Outputs.css+++ b/frontend/src/components/editor/output/Outputs.css@@ -26,6 +26,24 @@max-width: 100%;}+.output {+ /* Unset max-width on .markdown. Instead, we will apply+ to individual elements so it does not affect UI elements in markdown. */+ .markdown {+ max-width: unset;++ > pre,+ > ul,+ div.codehilite,+ /* Target <span> that is not empty and does not consist entirely of child elements;+ * this makes sure text with embedded HTML (such as a slider) has a max width,+ * but standalone elements (like tables, plots) don't get a max width. */+ > span.paragraph:not(:has(> :only-child)):not(:empty) {+ max-width: var(--markdown-max-width);+ }+ }+}+.stdout,.stderr,.marimo-error {diff --git a/frontend/src/css/globals.css b/frontend/src/css/globals.cssindex 87e6b5145d..0e888ccbb3 100644--- a/frontend/src/css/globals.css+++ b/frontend/src/css/globals.css@@ -44,6 +44,8 @@--text-font: var(--marimo-text-font, "PT Sans", sans-serif);--heading-font: var(--marimo-heading-font, "Lora", serif);--radius: 8px;+ /* stylelint-disable-next-line unit-allowed-list */+ --markdown-max-width: 80ch;/* Radix light colors: https://github.com/radix-ui/colors/blob/main/src/light.ts */diff --git a/frontend/src/css/katex.min.css b/frontend/src/css/katex.min.cssindex 5243249c30..bdabba4e1b 100644--- a/frontend/src/css/katex.min.css+++ b/frontend/src/css/katex.min.css@@ -6,6 +6,7 @@font-size: 110%;line-height: inherit;text-indent: 0;+ max-width: var(--markdown-max-width);}.katex * {diff --git a/frontend/src/css/md.css b/frontend/src/css/md.cssindex bbec3e8ba0..2c381462ed 100644--- a/frontend/src/css/md.css+++ b/frontend/src/css/md.css@@ -12,7 +12,7 @@}.markdown h1 {- text-align: center;+ text-align: start;}.config-width-full .markdown h1 {diff --git a/marimo/_runtime/control_flow.py b/marimo/_runtime/control_flow.pyindex 6575df1e34..843fd64063 100644--- a/marimo/_runtime/control_flow.py+++ b/marimo/_runtime/control_flow.py@@ -38,7 +38,7 @@ def stop(predicate: bool, output: Optional[object] = None) -> None:```Raises:- MarimoStopError: When `predicate` is `True`, raises a `MarimoStopError`.+ MarimoStopError: When `predicate` is `True`"""if predicate:raise MarimoStopError(output)diff --git a/marimo/_smoke_tests/issues/4548_md_max_width.py b/marimo/_smoke_tests/issues/4548_md_max_width.pynew file mode 100644index 0000000000..8e0a26d30d--- /dev/null+++ b/marimo/_smoke_tests/issues/4548_md_max_width.py@@ -0,0 +1,41 @@+++import marimo++__generated_with = "0.12.9"+app = marimo.App(width="medium")+++def _():+ import marimo as mo++ md = mo.md(+ "> long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here long text goes here"+ )+ md+ return md, mo+++def _():+ import polars as pl++ pl.DataFrame({"A": [1, 2, 3]})+ return+++def _(md, mo):+ mo.vstack([md])+ return+++def _(md, mo):+ mo.vstack([mo.hstack([md])])+ return+++if __name__ == "__main__":+ app.run()