anywidget-generator

Installation
Summary

Generate interactive anywidget components for marimo notebooks with vanilla JavaScript and CSS.

  • Create custom widgets by defining _esm (JavaScript render function) and _css (styled for light and dark modes) within an anywidget.AnyWidget subclass
  • Use traitlets to define reactive state properties that sync between Python and JavaScript via model.get(), model.set(), and change listeners
  • Wrap widgets with mo.ui.anywidget() for display in marimo cells and access state via widget.value dictionary
  • For complex widgets, point _esm and _css to external files using pathlib to keep code organized and maintainable
SKILL.md

When writing an anywidget use vanilla javascript in _esm and do not forget about _css. The css should look bespoke in light mode and dark mode. Keep the css small unless explicitly asked to go the extra mile. When you display the widget it must be wrapped via widget = mo.ui.anywidget(OriginalAnywidget()). You can also point _esm and _css to external files if needed using pathlib. This makes sense if the widget does a lot of elaborate JavaScript or CSS.

Related skills
Installs
1.4K
GitHub Stars
134
First Seen
Feb 10, 2026