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
feat: Add callout titles, unify callout and admonition styling (#10312)
Akshay Agrawal8c1721f3e885
diff --git a/frontend/src/components/editor/output/CalloutOutput.styles.ts b/frontend/src/components/editor/output/CalloutOutput.styles.tsdeleted file mode 100644index 4c416e5b1f..0000000000--- a/frontend/src/components/editor/output/CalloutOutput.styles.ts+++ /dev/null@@ -1,22 +0,0 @@-/* Copyright 2026 Marimo. All rights reserved. */-import { cva } from "class-variance-authority";--export const calloutStyles = cva(- "border rounded-lg p-12 mt-12 mb-12 text-foreground shadow-[4px_4px_0px_0px]",- {- variants: {- kind: {- neutral: "border-(--slate-9) shadow-(color:--slate-8)",- // @deprecated, use danger instead- alert: "bg-(--red-2) border-(--red-9) shadow-(color:--red-8)",- info: "bg-(--sky-1) border-(--sky-8) shadow-(color:--sky-7)",- danger: "bg-(--red-2) border-(--red-9) shadow-(color:--red-8)",- warn: "bg-(--amber-2) border-(--amber-9) shadow-(color:--amber-8)",- success: "bg-(--grass-2) border-(--grass-9) shadow-(color:--grass-8)",- },- },- defaultVariants: {- kind: "neutral",- },- },-);diff --git a/frontend/src/components/editor/output/CalloutOutput.tsx b/frontend/src/components/editor/output/CalloutOutput.tsxindex 6c540656d9..1a1187847a 100644--- a/frontend/src/components/editor/output/CalloutOutput.tsx+++ b/frontend/src/components/editor/output/CalloutOutput.tsx@@ -1,17 +1,31 @@/* Copyright 2026 Marimo. All rights reserved. */import { memo } from "react";import type { Intent } from "@/plugins/impl/common/intent";-import { calloutStyles } from "./CalloutOutput.styles";+import { cn } from "@/utils/cn";import { HtmlOutput } from "./HtmlOutput";interface Props {html: string;kind: Intent;+ title?: string;}-export const CalloutOutput: React.FC<Props> = memo(({ html, kind }) => {+// Callouts share the flat admonition style of markdown admonitions+// (css/admonition.css); each intent maps onto an admonition kind.+const KIND_CLASS: Record<Intent, string> = {+ neutral: "neutral",+ info: "info",+ warn: "warning",+ success: "success",+ danger: "danger",+ // 'alert' is deprecated; render as danger+ alert: "danger",+};++export const CalloutOutput: React.FC<Props> = memo(({ html, kind, title }) => {return (- <div className={calloutStyles({ kind })}>+ <div className={cn("admonition", KIND_CLASS[kind])}>+ {title && <span className="admonition-title">{title}</span>}<HtmlOutput html={html} alwaysSanitizeHtml={true} /></div>);diff --git a/frontend/src/css/admonition.css b/frontend/src/css/admonition.cssindex 95b84fd608..eadc86950e 100644--- a/frontend/src/css/admonition.css+++ b/frontend/src/css/admonition.css@@ -1,32 +1,53 @@@reference "../css/globals.css";+/*+ * Flat, GitHub-style admonitions.+ *+ * Icons are lucide (https://lucide.dev/icons/) data URIs applied as masks so+ * they render in currentColor.+ */+.admonition {- --admonition-bg: var(--blue-2);- --admonition-border: var(--blue-8);--admonition-heading-color: var(--blue-11);+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>');display: flex;- position: relative;flex-direction: column;- padding: 1rem;- padding-left: 3rem;- border-left: 4px solid;+ padding: 0.5rem 1rem;+ border-left: 0.25rem solid var(--admonition-heading-color);margin-bottom: 1rem;- background-color: var(--admonition-bg);- border-color: var(--admonition-border);- &::before {- position: absolute;- margin-top: 0.35rem;- margin-left: -2rem;+ /* Tighten the gap between the title and body (md.css gives paragraphs a+ 1rem block margin; flex children don't collapse margins). */+ & > .paragraph,+ & > p {+ margin-block: 0.375rem;+ }++ /* The paragraph right after the title hugs it, matching callouts, whose+ body is nested in a wrapper and gets the md.css :first-child treatment. */+ & > .admonition-title + .paragraph,+ & > .admonition-title + p {+ margin-block-start: 0;}}.admonition-title {- font-weight: bold;+ display: block;+ margin-bottom: 0.25rem;+ font-weight: 600;color: var(--admonition-heading-color);- @apply tracking-wide;+ &::before {+ content: "";+ display: inline-block;+ width: 1rem;+ height: 1rem;+ margin-right: 0.5rem;+ vertical-align: -0.125rem;+ background-color: currentcolor;+ mask: var(--admonition-icon) no-repeat center / contain;+ }> .paragraph {margin: 0;@@ -38,90 +59,50 @@}}-/* Icons from https://lucide.dev/icons/ */-.admonition.info,.admonition.note {- --admonition-bg: var(--blue-2);- --admonition-border: var(--blue-8);--admonition-heading-color: var(--blue-11);-- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="admonition-icon lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="admonition-icon lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>')- );- }+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>');}.admonition.danger,.admonition.caution,.admonition.error {- --admonition-bg: var(--red-2);- --admonition-border: var(--red-8);--admonition-heading-color: var(--red-11);-- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-octagon-alert"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-octagon-alert"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>')- );- }+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-octagon-alert"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>');}.admonition.attention,.admonition.warning {- --admonition-bg: var(--yellow-2);- --admonition-border: var(--yellow-8);--admonition-heading-color: var(--yellow-11);-- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>')- );- }+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>');}.admonition.hint {- --admonition-bg: var(--gray-2);- --admonition-border: var(--gray-8);--admonition-heading-color: var(--gray-11);-- .dark & {- --admonition-bg: var(--gray-3);- }-- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>')- );- }+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>');}.admonition.important {- --admonition-bg: var(--cyan-2);- --admonition-border: var(--cyan-8);--admonition-heading-color: var(--cyan-11);+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-message-square-warning"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M12 7v2"/><path d="M12 13h.01"/></svg>');+}- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-message-square-warning"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M12 7v2"/><path d="M12 13h.01"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-message-square-warning"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M12 7v2"/><path d="M12 13h.01"/></svg>')- );- }+.admonition.success {+ --admonition-heading-color: var(--grass-11);+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-check"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>');}.admonition.tip {- --admonition-bg: var(--grass-2);- --admonition-border: var(--grass-8);--admonition-heading-color: var(--grass-11);+ --admonition-icon: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-lightbulb"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>');+}- &::before {- content: light-dark(- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-lightbulb"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>'),- url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" opacity="60%" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-lightbulb"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/></svg>')- );+/* Quiet, icon-less variant used by neutral callouts. */+.admonition.neutral {+ --admonition-heading-color: var(--gray-11);++ .admonition-title::before {+ content: none;}}diff --git a/frontend/src/plugins/layout/CalloutPlugin.tsx b/frontend/src/plugins/layout/CalloutPlugin.tsxindex 6fea6ad252..4e64706407 100644--- a/frontend/src/plugins/layout/CalloutPlugin.tsx+++ b/frontend/src/plugins/layout/CalloutPlugin.tsx@@ -18,6 +18,10 @@ interface Data {* The kind of callout*/kind: Intent;+ /**+ * An optional bold title line+ */+ title?: string;}export class CalloutPlugin implements IStatelessPlugin<Data> {@@ -26,9 +30,12 @@ export class CalloutPlugin implements IStatelessPlugin<Data> {validator = z.object({html: z.string(),kind: zodIntent,+ title: z.string().optional(),});render({ data }: IStatelessPluginProps<Data>): JSX.Element {- return <CalloutOutput html={data.html} kind={data.kind} />;+ return (+ <CalloutOutput html={data.html} kind={data.kind} title={data.title} />+ );}}diff --git a/frontend/src/stories/callout.stories.tsx b/frontend/src/stories/callout.stories.tsxindex 9f667b686f..89f8c653c9 100644--- a/frontend/src/stories/callout.stories.tsx+++ b/frontend/src/stories/callout.stories.tsx@@ -71,3 +71,15 @@ export const Success = {name: "success",};++export const WithTitle = {+ render: () => (+ <CalloutOutput+ html="<p>CalloutOutput with a title and <strong>HTML</strong></p>"+ kind="warn"+ title="Watch out"+ />+ ),++ name: "with title",+};diff --git a/marimo/_output/hypertext.py b/marimo/_output/hypertext.pyindex 8700d62c45..c607cb65f2 100644--- a/marimo/_output/hypertext.py+++ b/marimo/_output/hypertext.py@@ -244,12 +244,14 @@ class Html(MIME):kind: Literal["neutral", "danger", "warn", "success", "info"] = "neutral",+ title: str | None = None,) -> Html:"""Create a callout containing this HTML element.- A callout wraps your HTML element in a raised box, emphasizing its- importance. You can style the callout for different situations with the- `kind` argument.+ A callout renders your HTML element in a flat, bordered box — the+ same style as markdown admonitions — emphasizing its importance. You+ can style the callout for different situations with the `kind`+ argument, and optionally add a bold `title` line.Examples:```python3@@ -257,13 +259,15 @@ class Html(MIME):``````python3- mo.md("It's dangerous to go alone!").callout(kind="warn")+ mo.md("It's dangerous to go alone!").callout(+ kind="warn", title="Warning"+ )```"""from marimo._plugins.stateless.callout import callout as _callout- return _callout(self, kind=kind)+ return _callout(self, kind=kind, title=title)@mddocdef style(diff --git a/marimo/_plugins/stateless/callout.py b/marimo/_plugins/stateless/callout.pyindex a1c75d88e6..2f4211d234 100644--- a/marimo/_plugins/stateless/callout.py+++ b/marimo/_plugins/stateless/callout.py@@ -6,7 +6,10 @@ from typing import Literalfrom marimo._output.formatting import as_htmlfrom marimo._output.hypertext import ContainerHtmlfrom marimo._output.rich_help import mddoc-from marimo._plugins.core.web_component import build_stateless_plugin+from marimo._plugins.core.web_component import (+ JSONType,+ build_stateless_plugin,+)CalloutKind = Literal["neutral", "warn", "success", "info", "danger"]@@ -18,19 +21,27 @@ class callout(ContainerHtml):Args:value: A value to render in the calloutkind: The kind of callout (affects styling).-+ title: An optional title."""def __init__(self,value: object,kind: CalloutKind = "neutral",+ title: str | None = None,) -> None:self._kind = kind+ self._title = titlesuper().__init__([as_html(value)])def _build_text(self) -> str:+ args: dict[str, JSONType] = {+ "html": self._children[0].text,+ "kind": self._kind,+ }+ if self._title is not None:+ args["title"] = self._titlereturn build_stateless_plugin(component_name="marimo-callout-output",- args={"html": self._children[0].text, "kind": self._kind},+ args=args,)diff --git a/marimo/_smoke_tests/callouts_and_admonitions.py b/marimo/_smoke_tests/callouts_and_admonitions.pynew file mode 100644index 0000000000..f88e81d238--- /dev/null+++ b/marimo/_smoke_tests/callouts_and_admonitions.py@@ -0,0 +1,227 @@+import marimo++__generated_with = "0.23.15"+app = marimo.App()+++def _():+ import marimo as mo++ return (mo,)+++def _(mo):+ mo.md(r"""+ # Markdown admonitions++ /// note | "Note"+ This is a `note` admonition, written in markdown.+ ///++ /// warning | "Warning"+ This is a `warning` admonition.+ ///++ /// danger | "Danger"+ This is a `danger` admonition.+ ///++ /// tip | "Tip"+ This is a `tip` admonition.+ ///+ """)+ return+++def _(mo):+ mo.vstack(+ [+ mo.md("# Callouts"),+ mo.callout(mo.md("A `neutral` callout, no title."), kind="neutral"),+ mo.callout(+ mo.md("An `info` callout with a title."),+ kind="info",+ title="Info"+ ),+ mo.callout(+ mo.md("A `warn` callout with a title."),+ kind="warn",+ title="Warning"+ ),+ mo.callout(+ mo.md("A `danger` callout with a title."),+ kind="danger",+ title="Danger"+ ),+ mo.callout(+ mo.md("A `success` callout with a title."),+ kind="success",+ title="Success"+ ),+ mo.md("The fluent API works too:"),+ mo.md("Hooray, you did it!").callout(kind="success")+ ]+ )+ return+++def _(mo):+ mo.md(r"""+ # Stress tests: rich content in callouts+ """)+ return+++def _():+ import matplotlib.pyplot as plt+ import numpy as np+ import polars as pl++ return np, pl, plt+++def _(mo, np, plt):+ fig, ax = plt.subplots(figsize=(6, 3))+ xs = np.linspace(0, 2 * np.pi, 200)+ ax.plot(xs, np.sin(xs))+ ax.set_title("sin(x)")+ mo.callout(ax, kind="info", title="A matplotlib plot")+ return+++def _(mo):+ stress_slider = mo.ui.slider(0, 100, value=50, label="Amplitude")+ stress_dropdown = mo.ui.dropdown(+ options=["sin", "cos", "tan"], value="sin", label="Function"+ )+ stress_text = mo.ui.text(placeholder="Type something...", label="Notes")+ stress_button = mo.ui.run_button(label="Run")+ mo.callout(+ mo.vstack(+ [+ mo.hstack([stress_slider, stress_dropdown], justify="start"),+ stress_text,+ stress_button,+ ]+ ),+ kind="warn",+ title="Interactive UI elements",+ )+ return stress_dropdown, stress_slider, stress_text+++def _(mo, stress_dropdown, stress_slider, stress_text):+ mo.callout(+ mo.md(+ f"Slider: `{stress_slider.value}`, dropdown: "+ f"`{stress_dropdown.value}`, text: `{stress_text.value!r}`"+ ),+ kind="success",+ title="Values react across cells",+ )+ return+++def _(mo, np, pl):+ df = pl.DataFrame(+ {+ "x": np.arange(10),+ "sin(x)": np.sin(np.arange(10)),+ "label": [f"row {i}" for i in range(10)],+ }+ )+ mo.callout(df, kind="neutral", title="A polars DataFrame")+ return (df,)+++def _(df, mo):+ stress_table = mo.ui.table(df, selection="multi", page_size=5)+ mo.callout(stress_table, kind="info", title="A selectable mo.ui.table")+ return+++def _(mo):+ mo.callout(+ mo.callout(+ mo.md(+ r"""+ A callout inside a callout, holding LaTeX+ ($e^{i\pi} + 1 = 0$), a markdown admonition:++ /// warning | Nested admonition+ Markdown admonitions render inside callouts too.+ ///++ and a code block:++ ```python+ def fib(n: int) -> int:+ return n if n < 2 else fib(n - 1) + fib(n - 2)+ ```+ """+ ),+ kind="danger",+ title="Inner callout",+ ),+ kind="neutral",+ title="Outer callout",+ )+ return+++def _(mo):+ mo.callout(+ mo.vstack(+ [+ mo.hstack(+ [+ mo.stat(value="42", label="Answer", caption="+3.2%"),+ mo.stat(value="1.7s", label="Runtime"),+ ],+ justify="start",+ ),+ mo.accordion(+ {"Details": mo.md("An accordion inside a callout.")}+ ),+ mo.ui.tabs(+ {+ "Tab A": mo.md("First tab"),+ "Tab B": mo.md("Second tab"),+ }+ ),+ ]+ ),+ kind="info",+ title="Stats, accordions, and tabs",+ )+ return+++def _(mo):+ mo.callout(+ mo.md("Edge cases: does the title escape `<b>HTML</b>` and emoji?"),+ kind="warn",+ title=(+ "A very long title with <b>HTML tags</b> & ampersands 🎉 that "+ "should be escaped, not rendered, and should wrap gracefully "+ "when it exceeds the width of the callout container"+ ),+ )+ return+++if __name__ == "__main__":+ app.run()diff --git a/marimo/_tutorials/intro.py b/marimo/_tutorials/intro.pyindex 7e2a0f4cc0..17056ee2a2 100644--- a/marimo/_tutorials/intro.py+++ b/marimo/_tutorials/intro.py@@ -8,7 +8,7 @@import marimo-__generated_with = "0.19.2"+__generated_with = "0.23.15"app = marimo.App()@@ -64,10 +64,10 @@ def _(mo):def _(mo):mo.md("""- Tip: This is a tutorial notebook. You can create your own notebooks- by entering `marimo edit` at the command line.+ This is a tutorial notebook. Create your own notebooks+ with `marimo edit` at the command line."""- ).callout()+ ).callout(kind="info", title="Creating your own notebooks")returndiff --git a/marimo/_tutorials/layout.py b/marimo/_tutorials/layout.pyindex c5e7f672bb..2dc0ec8149 100644--- a/marimo/_tutorials/layout.py+++ b/marimo/_tutorials/layout.py@@ -8,7 +8,7 @@import marimo-__generated_with = "0.19.7"+__generated_with = "0.23.15"app = marimo.App()@@ -324,13 +324,11 @@ def _(mo):def _(callout_kind, mo):mo.md(f"""- **This is a callout!**-You can turn any HTML or markdown into an emphasized callout.- You can choose from a variety of different callout kind. This one is:+ You can choose from a variety of callout kinds. This one is:{callout_kind}"""- ).callout(kind=callout_kind.value)+ ).callout(kind=callout_kind.value, title="This is a callout!")returndiff --git a/marimo/_tutorials/markdown.py b/marimo/_tutorials/markdown.pyindex df29a2c4c0..241730d97a 100644--- a/marimo/_tutorials/markdown.py+++ b/marimo/_tutorials/markdown.py@@ -11,7 +11,7 @@import marimo-__generated_with = "0.23.6"+__generated_with = "0.23.15"app = marimo.App()@@ -60,6 +60,23 @@ def _(mo):return[email protected](hide_code=True)+def _(mo):+ mo.md(r"""+ /// Tip | Admonitions+ Write admonitions or callouts with the following syntax:+ ```text+ /// Tip | Title+ Admonition text body+ ///+ ```++ Supported kinds include Note, Tip, Hint, Important, Warning, and Danger.+ ///+ """)+ return++@app.cell(hide_code=True)def _(mo):mo.md(r"""@@ -95,31 +112,24 @@ def _(mo):@app.cell(hide_code=True)def _(mo):- mo.accordion(- {- "Tip: `r''` strings": mo.md(- "Use `r''` strings to remove the need to escape backslashes"- " when writing LaTeX."- )- }- )+ mo.md(r"""+ /// Note | `r''` strings+ Use `r''` strings to remove the need to escape backslashes when writing LaTeX.+ ///+ """)return@app.cell(hide_code=True)def _(mo):- mo.accordion(- {- "Note: KaTeX": mo.md(- """- marimo actually uses KaTeX, a math typesetting library for the- web which supports a subset of LaTeX. For a list of- (un)supported commands, visit- https://katex.org/docs/support_table- """- )- }- )+ mo.md(r"""+ /// Note | KaTeX+ marimo uses KaTeX, a math typesetting library for the+ web which supports a subset of LaTeX. For a list of+ (un)supported commands, visit+ https://katex.org/docs/support_table+ ///+ """)return@@ -144,7 +154,6 @@ def _(mo, np, plt):plt.plot(_x, np.sin(_x))return plt.gca()-mo.md(f"""### Plots@@ -211,13 +220,11 @@ def _(mo):def _(mo, np):import polars as pl-def make_dataframe():x = np.linspace(0, 2 * np.pi, 10)y = np.sin(x)return pl.DataFrame({"x": x, "sin(x)": y})-mo.md(f"""### Other objectsdiff --git a/marimo/_tutorials/ui.py b/marimo/_tutorials/ui.pyindex 78d383a33c..8453bb13e8 100644--- a/marimo/_tutorials/ui.py+++ b/marimo/_tutorials/ui.py@@ -8,7 +8,7 @@import marimo-__generated_with = "0.23.6"+__generated_with = "0.23.15"app = marimo.App()@@ -123,7 +123,7 @@ def _(mo):See our [examples folder](https://github.com/marimo-team/marimo/tree/main/examples/ui) on GitHub for bite-sized notebooks showcasing all our UI elements. Fora more detailed reference, see our [API docs](https://docs.marimo.io/api/inputs/)."""- ).callout()+ ).callout(kind="info", title="Examples and API reference")returndiff --git a/tests/_plugins/stateless/test_callout.py b/tests/_plugins/stateless/test_callout.pyindex b17dec91bd..42575236bc 100644--- a/tests/_plugins/stateless/test_callout.py+++ b/tests/_plugins/stateless/test_callout.py@@ -19,6 +19,15 @@ def test_callout_renders_child() -> None:assert "Important" in result.text+def test_callout_with_title() -> None:+ result = callout(Html("<p>Important</p>"), kind="warn", title="Heads up")+ assert "Heads up" in result.text++ # No title arg -> no title attribute in the rendered component.+ result = callout(Html("<p>Important</p>"), kind="warn")+ assert "data-title" not in result.text++def test_callout_retains_strong_reference_to_child() -> None:# Regression test: callout() must keep a strong reference to its child so# that wrapped UI elements are not garbage collected (the UI registry holds