Public
Edited
Nov 27, 2022
1 fork
14 stars
Insert cell
Insert cell
viewof form = Inputs.form({
option1: Inputs.checkbox(["A", "B"], {label: "Select some"}),
option2: Inputs.range([0, 100], {label: "Amount", step: 1})
})
Insert cell
Insert cell
form
Insert cell
Insert cell
viewof rgb = Inputs.form([
Inputs.range([0, 255], {step: 1, label: "r"}),
Inputs.range([0, 255], {step: 1, label: "g"}),
Inputs.range([0, 255], {step: 1, label: "b"})
], {template: inputs => htl.html`<details open>
<summary>Color</summary>
${inputs}
</details>`})
Insert cell
rgb
Insert cell
Insert cell
viewof rgb1 = Inputs.form({
r: Inputs.range([0, 255], {step: 1, label: "r"}),
g: Inputs.range([0, 255], {step: 1, label: "g"}),
b: Inputs.range([0, 255], {step: 1, label: "b"})
}, {template: inputs => htl.html`<details open>
<summary>Color</summary>
${Object.values(inputs)}
</details>`})
Insert cell
rgb1
Insert cell
Insert cell
viewof nestedForm = Inputs.form([
Inputs.form({
a: Inputs.range([0, 100], { label: "Amount", step: 1 }),
b: Inputs.select(["A", "B"], { label: "Select one" })
}),
Inputs.form({
a: Inputs.range([0, 100], { label: "Number", step: 1 }),
b: Inputs.checkbox(["C", "D", "E"], { label: "Select any" })
})
], {template: inputs => htl.html`<div>
<details><summary>Section 1</summary>${inputs[0]}</details>
<details><summary>Section 2</summary>${inputs[1]}</details>
</div>`})
Insert cell
nestedForm
Insert cell
Insert cell
Inputs.form([
Inputs.range([0, 255], {step: 1, label: "r"}),
Inputs.range([0, 255], {step: 1, label: "g"}),
Inputs.range([0, 255], {step: 1, label: "b"})
], {template: inputs => htl.html`<details class="styled">
<summary>Color</summary>
${inputs}
</details>
<style>
details.styled {
border: 1px solid black;
border-radius: 5px;
padding: 10px;
}
details.styled summary {
list-style: none;
cursor: pointer;
border-bottom: 1px solid transparent;
}
details.styled summary:hover {
font-style: italic;
border-bottom: 1px solid #ccc;
}
details.styled[open] {
background: #eee;
}
details.styled[open] summary {
border-bottom: 1px solid black;
margin-bottom: 1rem;
}
</style>
`})
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more