The p-radio-group can be integrated into a form in two ways: controlled or uncontrolled, depending on your
needs.
In the controlled approach, the p-radio-group state is externally managed using the value property and change
event to keep it in sync with your application logic. This approach is ideal for complex forms or when using a form
library. Note that the component will still always update its internal value automatically when interacted with.
In the uncontrolled approach, the p-radio-group automatically managing its own state and includes its value in
form submissions through the ElementInternals API.
This is convenient for smaller forms or simple submissions.
For more details on form integration, refer to the Form section in the
developing documentation for your framework of choice, or find a full form integration
example in our examples repository.
Sometimes it's useful to be able to render markup (e.g. an anchor tag) for label, description or message.
Therefore, a named slot can be used. Make sure not to define the corresponding property on the host element when a
named slot is used (because a property definition is preferred over a named slot). For named slots only
phrasing content is
allowed.
Some label with a link.Some description with a link.Some error message with a link.
prev
next
Open in Stackblitz
<!doctype html>
<htmllang="en"class="auto"><head><title></title></head><bodyclass="bg-canvas"><p-radio-groupstate="error"value="a"><spanslot="label"id="some-label-id"> Some label with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span><spanslot="description"id="some-description-id"> Some description with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span><spanslot="message"id="some-message-id"> Some error message with a
<ahref="https://designsystem.porsche.com"> link
</a> .
</span><p-radio-group-optionvalue="a"label="Option A"></p-radio-group-option><p-radio-group-optionvalue="b"label="Option B"></p-radio-group-option><p-radio-group-optionvalue="c"label="Option C"></p-radio-group-option><p-radio-group-optionvalue="d"label="Option D"></p-radio-group-option><p-radio-group-optionvalue="e"label="Option E"></p-radio-group-option><p-radio-group-optionvalue="f"label="Option F"></p-radio-group-option></p-radio-group><script></script></body></html>