The p-segmented-control component is a form-associated custom element that integrates seamlessly with forms. Leveraging the
ElementInternals API, it functions similar to a
native select, ensuring compatibility with form behaviors. However, note that browser support for this API is limited.
When used within a form element, it's required to provide a name attribute to the p-segmented-control component. This
attribute establishes the link between the component and the form, enabling the selected value to be included in the
form's data when it's submitted.
Attention
The p-segmented-control lacks access to native ValidityState
properties and validationMessage, and it cannot display the native validation popover. This means validation behavior
and error display will need to be implemented separately if required.
In the controlled approach, the p-segmented-control component is externally controlled. Selected items trigger a custom
update event, allowing you to use the updated value. Internally, the value will be updated automatically but can be
overwritten by passing in a new value.