Form Components
A runnable demo of vUX-formComponents.js, exercising all six builders: select, radio, checkbox, datePicker, slideSwitch and file. See the Form Components guide for the full API.
Live example
Runs the module from this site, with every control on the page. Open it in its own tab for the full layout.
The page
| Section | Shows |
|---|---|
| Hero | a select, a switch and a radio group: built by the same autoBuild() calls as the rest of the page |
| 01 All six builders | every widget, in four panels |
| 02 Two attribute conventions | full attribute name vs dataset name, and rebuilding content added later |
| 03 Native change log | one delegated listener proving the native input holds the state |
| 04 Bad input | the eight ways the builders reject config, including an incomplete autoBuild() |
The controls
| Widget | Native input | Shows |
|---|---|---|
| Fruit select | <select> | <optgroup>, a disabled option, the search box, keyboard navigation, refreshSelect() after adding an option |
| Toppings select | <select multiple> | toggle-to-select, comma label, full list as a tooltip (selectFieldToolTip) |
| Plan radios | <input type="radio"> ×3 | a horizontal group (axisClass), label clicks, single-selection forwarding |
| Checkboxes | <input type="checkbox"> ×2 | a content-supplied check glyph, clickable labels |
| Date of birth | <input type="date"> | min/max, a preset value, decade → year → month → day drill-down, weekday tooltips (daysToolTip) |
| Meeting | <input type="datetime-local"> | the same flow plus hour/minute entry and the AM/PM switch |
| Switches | <input type="checkbox"> | data-dim/data-labels attributes, on/off styling, refresh() on an injected switch |
| Attachment | <input type="file"> | label + browse button, file-name tooltip, button icon |
What it demonstrates
The native input stays the source of truth. The "native change log" at the bottom uses one delegated
changelistener: every entry is fired by a hidden native input, so each line proves a widget wrote its state through.The date picker writes attributes, not events: the two
value: … | complete: …state lines are driven by aMutationObserverwatching the native input'svalueanddata-complete(the configuredvalidationAttribute) attributes.Leap years, open the date-of-birth picker and pick February 2024: it has 29 days.
Dynamic content: "Add option + refreshSelect()" mutates the native select and rebuilds one widget; "Inject a new switch + refresh()" inserts brand-new checkbox markup and converts it.
The two attribute conventions: the select and date picker take full attribute names (
sizeAttribute: "data-size"), while the slide switch and file input takedatasetnames without the prefix (dataAttributeNames: { size: "dim" }).The slide-switch markup rule: each switch checkbox is the last element child of its own wrapper
DIV, with the text label outside it.Glyphs supplied entirely through config
content(the checkbox check mark, the calendar and folder icons, the search icon): no icon font needed.Bad input fails immediately: section 04 performs each bad call and prints what was thrown.
All six builders are exposed on window.demoForm for the console, e.g. demoForm.select.refresh().
Styling
The page uses the shared example design system at ../shared/example.css. The widgets themselves are styled through builder config instead, because the component generates their stylesheets: main.js keeps the page's palette in one T object and interpolates it into the config strings, so the widget colours and the page stylesheet cannot drift apart. That is the pattern to copy: the component ships structure, the consuming page supplies the look.