Mask the visual appearance of a checkbox which has a state in-between checked and unchecked.
This is especially useful for a checkbox that is used to set the state of a group of checkboxes at once. However, this
group might have a mixed state. In this case we recommend to use checked=false and indeterminate=true.
Note: The indeterminate attribute only affects how the checkbox is shown. The current value is hidden from the user,
but the checkbox still keeps it's checked state. You can find more details in
the specification.
The p-checkbox component is a form-associated custom element that integrates seamlessly with forms. Leveraging the
ElementInternals API, it functions like a native
checkbox, ensuring compatibility with form behaviors. However, note that browser support for this API is limited.
In the controlled approach, the p-checkbox checked state is externally managed. While the internal checked state will
be updated automatically, you can use the update or blur event to update the external state.
Sometimes it's useful to be able to render markup (e.g. an anchor tag) for label 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 linkSome error message with a link
prev
next
Open in Stackblitz
<!doctype html>
<htmllang="en"class="auto"><head><title></title></head><bodyclass="bg-base"><p-checkboxstate="error"name="some-name"aria-labelledby="some-label-id"aria-describedby="some-message-id"><spanslot="label"id="some-label-id"> Some label 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-checkbox><script></script></body></html>