A custom element placed inside a form does not submit data by default. Mark the class as form-associated, connect it to ElementInternals, and provide the value the form should submit. section 3.9
Implement form participation in these steps:
- Declare static formAssociated = true; on the custom-element class, rather than in the constructor or an instance method. section 3.9
- Store an ElementInternals object from attachInternals(). section 3.9
- Call setFormValue() initially and whenever the component value changes; pass either one value or a FormData object. section 3.9
- Use formAssociatedCallback() to save initial values and formResetCallback() to restore them when the form resets. section 3.9
Submitting a temperature gauge
For <temperature-gauge name="temperature">, calling this.#internals.setFormValue(someValue) submits one value under the key temperature. A component submitting multiple values can create FormData, set color and size entries, and pass that object to setFormValue(). section 3.9
#internals = this.attachInternals();
Inspect the ElementInternals declaration used to connect the component with form behavior. section 3.9

