Published
Edited
Feb 8, 2018
1 fork
Importers
9 stars
Insert cell
Insert cell
Insert cell
viewof v1 = html`<input type=checkbox>`
Insert cell
v1
Insert cell
Insert cell
viewof v2 = html`<label><input type=checkbox>Toggle me!</label>`
Insert cell
v2
Insert cell
Insert cell
checkbox = ({label = '', value = false} = {}) => {
let wrapper = html`<label></label>`
let check = html`<input type=checkbox>`
wrapper.append(check)
wrapper.append(label || '')
check.checked = value
check.addEventListener('change', (e) => {
wrapper.value = check.checked
wrapper.dispatchEvent(new CustomEvent('input'))
})
// we need to have a starting value
wrapper.value = check.checked
return wrapper
}
Insert cell
viewof v3 = checkbox({label: 'Now toggle ME!', value: true})
Insert cell
v3
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