Porsche Design System
You are currently viewing an earlier release of the Porsche Design System.Switch to the latest Porsche Design System documentation.
SearchNavigate to GitHub repository of Porsche Design SystemOpen sidebar
ConfiguratorExamplesUsageAccessibilityAPI
Checkbox Table of Contents Form The p-checkbox can be integrated into a form in two ways: controlled or uncontrolled, depending on your needs. In the controlled approach, the checkbox state is externally managed using the checked 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 checkbox behaves similar to a native <input type="checkbox" />, automatically managing its own state and including 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.
SubmitReset
Last submitted data:
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-canvas">

<form class="flex flex-col gap-fluid-sm">
  <p-checkbox name="myCheckbox" label="Some Label"></p-checkbox>
  <div class="flex gap-fluid-sm">
    <p-button type="submit">Submit</p-button>
    <p-button type="reset">Reset</p-button>
  </div>
  <p-text>Last submitted data: </p-text>
</form>
<script>
  const debugElement = document.querySelector('p-text');
  const form = document.querySelector('form');
  form.addEventListener('submit', (e) => {
    e.preventDefault();
    const formData = new FormData(form);
    debugElement.innerText = `Last submitted data: ${formData.get('myCheckbox')}`;
  });
</script>
</body>
</html>
Indeterminate 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.
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-canvas">

<p-checkbox label="Some label" indeterminate="true"></p-checkbox>

<p-checkbox label="Some label" indeterminate="true" checked="true"></p-checkbox>
<script>

</script>
</body>
</html>
Slots Sometimes it's useful to render custom markup for label or message. Therefore, named slots 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. In addition to the named slots label and message, there is also a label-after slot available. This slot must be used to render content after the label which is not directly part of it (e.g. an external link or a popover component). If the p-checkbox is in disabled/loading state and label or label-after slots are used with focusable UI elements (e.g. a or p-popover), the keyboard focus handling has to be managed manually to prevent focusing disabled elements (e.g. add tabindex="-1" on those UI elements).
Some slotted label with custom content and a "label-after" slotSome label with a linkSome slotted labelSome slotted label with a nested linkSome error message with a link
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-canvas">

<div class="flex flex-col gap-static-sm">
  <p-checkbox state="error" name="some-name">
    <span slot="label">
      <img src="assets/911.png" alt="" class="object-contain inline-block align-middle -mt-2 me-static-sm w-[70px]" />
      Some slotted label with custom content and a "label-after" slot
    </span>
    <p-popover slot="label-after" class="ms-static-xs">
      Some label with a 
      <a href="https://designsystem.porsche.com" class="underline">
        link
      </a>
    </p-popover>
  </p-checkbox>
  <p-checkbox state="error" name="some-name">
    <span slot="label">
      Some slotted label
    </span>
  </p-checkbox>
  <p-checkbox state="error" name="some-name">
    <span slot="label">
      Some slotted label with a nested 
      <a href="https://www.porsche.com" class="underline">
        link
      </a>
    </span>
    <span slot="message">
      Some error message with a 
      <a href="https://designsystem.porsche.com" class="underline">
        link
      </a>
    </span>
  </p-checkbox>
</div>
<script>

</script>
</body>
</html>
Global settingsThemeChanges the theme of the application and any Porsche Design System component. It's possible to choose between forced theme light and dark. It's also possible to use auto, which applies light or dark theme depending on the operating system settings automatically.LightDarkAuto (sync with operating system)DirectionThe dir global attribute in HTML changes the direction of text and other content within an element. It's most often used on the <html> tag to set the entire page's direction, which is crucial for supporting languages that are written from right to left (RTL), such as Arabic and Hebrew. For example, using <html dir="rtl"> makes the entire page display from right to left, adjusting the layout and text flow accordingly.LTR (left-to-right)RTL (right-to-left)Text ZoomTo ensure accessibility and comply with WCAG 2.2 AA standards, it is mandatory for web content to support text resizing up to at least 200% without loss of content or functionality. Using relative units like rem is a best practice for achieving this, as they allow the text to scale uniformly based on the user's browser settings.100%130%150%200%