Published
Edited
Jul 23, 2021
3 stars
Also listed in…
Working Libraries
Insert cell
Insert cell
Insert cell
se = require("slide-element")
Insert cell
html`<div class="examples">

<div class="example">
<button id="toggleButton">Toggle It</button>
<div class="box" id="toggleExample">
<span>These contents will toggle. For most use cases, this is probably the method you'll use in the wild. Clicking the button again will cause the box to open and closed based on its current state (obviously).</span>
</div>
</div>
</div>`
Insert cell
Insert cell
// toggle() example
document.getElementById('toggleButton').addEventListener('click', (e) => {
se.toggle(document.getElementById('toggleExample')).then(isOpen => {
e.target.innerText = `It's ${isOpen ? 'open' : 'closed'}!`;
});
});
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