Created
August 1, 2025 10:13
-
-
Save poke1024/3d8b969c597c851a1c5765ef527bc6af to your computer and use it in GitHub Desktop.
SolidJS inside anywidget (marimo)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import anywidget | |
| import traitlets | |
| import marimo as mo | |
| class ExampleWidget(anywidget.AnyWidget): | |
| _esm = """ | |
| import { | |
| createSignal, | |
| onCleanup, | |
| } from "https://cdn.skypack.dev/solid-js"; | |
| import { render as renderSolidJS } from "https://cdn.skypack.dev/solid-js/web"; | |
| import html from "https://cdn.skypack.dev/solid-js/html"; | |
| function render({ model, el }) { | |
| const App = () => { | |
| const [count, setCount] = createSignal(0); | |
| const click = (e) => {setCount(count() + 1)}; | |
| return html`<div onClick=${click}>${count}</div>`; | |
| }; | |
| renderSolidJS(App, el); | |
| } | |
| export default { render }; | |
| """ | |
| widget = mo.ui.anywidget(ExampleWidget()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment