A few of my components from wigglystuff have graduated and are now part of marimo. The whole point of the library is to have a place for fun and experimental tools. But after they turn out to be useful they're easy to port into the core project.
That's why, ever since version 0.20.0 you can now directly use the matrix widget, pytorch widget and chart-select widget without installing the plugin.
Having these widgets in marimo is great, but it also means that it became time to add a deprecation notice. However, because these widgets can also be used from Jupyter we don't just want to show the deprecation message to everyone. Only to marimo users.
That means that we need to check if the component is being used from marimo. That's easy enough.
try:
import marimo as mo
except ImportError:
return
The cool thing though, is that if we know that we are in marimo ... we also know that we are in a browser. And that means we can also do better than just return a Python warning. We can generate a bespoke callout.
from __future__ import annotations
_STYLE = (
"font-size: 0.875em; "
"padding: 8px 12px; margin: 8px 0; "
"border-left: 3px solid #f59e0b; "
"background: rgba(245, 158, 11, 0.10); "
"border-radius: 0 4px 4px 0;"
)
def warn_if_in_marimo(widget_name: str, message_html: str) -> None:
"""Render a small graduation hint in the cell when running inside marimo.
No-op in plain Jupyter or non-notebook contexts so users without a
marimo built-in alternative are not bothered.
``message_html`` is treated as raw HTML so call sites can embed
``<a href="...">`` links and ``<code>`` tags directly.
"""
try:
import marimo as mo
except ImportError:
return
if not mo.running_in_notebook():
return
html = (
f'<div style="{_STYLE}">'
f"<code>wigglystuff.{widget_name}</code>"
f" has graduated to marimo core. {message_html}"
f"</div>"
)
mo.output.append(mo.Html(html))
Now, if you're in marimo, you don't just get text. You actually get to see this gentle callout with a proper clickable link.
Such a nice pattern!