Skip to content

Instantly share code, notes, and snippets.

@manzt
Created July 10, 2023 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manzt/4f16aeb0f8b38733d333a5180d9fc54d to your computer and use it in GitHub Desktop.
Save manzt/4f16aeb0f8b38733d333a5180d9fc54d to your computer and use it in GitHub Desktop.
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