Public
Edited
Apr 25
Importers
Insert cell
Insert cell
function OnClickButton(label, opts) {
const btn = Inputs.button(label, opts);
if (opts.onClick) {
btn.addEventListener("click", opts.onClick);
}

if (opts.class) {
[...btn.getElementsByTagName("button")].forEach((b) =>
b.setAttribute("class", opts.class)
);
}
if (opts.style) {
btn.style = opts.style;
}

return btn;
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more