For the Documentation of Inputs.form(), it indicates that we can use a template
to rearrange how the form controls are laid out.
The template code seems to show an overly simple example such as
function arrayTemplate(inputs) {
return html`<div>${inputs}`;
}
...
function objectTemplate(inputs) {
return html`<div>${Object.values(inputs)}`;
}
My understanding is that we would just be passing in the html literal value, I just included the whole functions as-is. The biggest issue is that I am relearning HTML and CSS and I am uncertain how to interop between the html and the Input.form
controls
As an example, right now I have the following Input.form
, and I am wondering how I would construct a template
.
viewof modifier = Inputs.form({
width: Inputs.range([0.1, 1], {
label: "Tree Width Modifier",
value: 1,
step: 0.1
}),
height: Inputs.range([0.6, 4], {
label: "Tree Height Modifier",
value: 1,
step: 0.1
}),
IndicatorEnabled: Inputs.toggle({
label: "Enable Indicators?",
value: false
}),
weekIndicator: Inputs.date({
label: "Indicators Since Week Of:",
min: "2021-11-24",
max: new Date()
})
})
Are there some good notebook examples that arenât linked in the documentation? I assume after seeing some examples, I could create some template
s by myself.
For some concrete layout ideas for templates:
- How would I go about creating 2 colomns and grouping the last 2
Input.form
controls together and shifting them to the top-right? - Is it possible to control the sizing of each of the 3 components for the
Inputs.range
control? - What about having 3 columns where the
Input.toggle
is in the middle and theInput.date
along with anInput.color
control are grouped together in the 3rd column?
Edit: One thing that I assume is that I donât have to define the whole html inputs using pure html only, as can be seen in Form Input / Mike Bostock | Observable. I assume there is some interop between the html literal and the existing Input controls within Input.form