Created
July 10, 2023 00:33
-
-
Save manzt/4f16aeb0f8b38733d333a5180d9fc54d to your computer and use it in GitHub Desktop.
This file contains 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 | |
class ExampleWidget(anywidget.AnyWidget): | |
_esm = """ | |
export function render({ model, el }) { | |
el.classList.add("custom-widget"); | |
function valueChanged() { | |
el.textContent = model.get("value"); | |
} | |
valueChanged(); | |
model.on("change:value", valueChanged); | |
} | |
""" | |
_css = """ | |
.custom-widget { | |
background-color: lightseagreen; | |
padding: 0px 2px; | |
} | |
""" | |
value = traitlets.Unicode("Hello World").tag(sync=True) | |
ExampleWidget() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment