Porsche Design SystemSearchNavigate to GitHub repository of Porsche Design SystemOpen sidebar
ConfiguratorExamplesUsageAccessibilityAPI
Segmented Control Table of Contents Form 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. 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.
Option 1Option 2Option 3Option 4Option 5
Last submitted data: none
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-base">

<form>
  <p-segmented-control name="options" value="1">
    <p-segmented-control-item value="1">Option 1</p-segmented-control-item>
    <p-segmented-control-item value="2">Option 2</p-segmented-control-item>
    <p-segmented-control-item value="3">Option 3</p-segmented-control-item>
    <p-segmented-control-item value="4">Option 4</p-segmented-control-item>
    <p-segmented-control-item value="5">Option 5</p-segmented-control-item>
  </p-segmented-control>
  <button type="submit">Submit</button>
  <button type="reset">Reset</button>
</form>

<p-text>Last submitted data: none</p-text>
<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('options') || 'none'}`;
  });
</script>
</body>
</html>
Controlled 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.
Option 1Option 2Option 3Option 4Option 5Current value: 1
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-base">

<p-segmented-control value="1">
  <p-segmented-control-item value="1">Option 1</p-segmented-control-item>
  <p-segmented-control-item value="2">Option 2</p-segmented-control-item>
  <p-segmented-control-item value="3">Option 3</p-segmented-control-item>
  <p-segmented-control-item value="4">Option 4</p-segmented-control-item>
  <p-segmented-control-item value="5">Option 5</p-segmented-control-item>
</p-segmented-control>

<p-text>Current value: 1</p-text>
<script>
  const segmentedControl = document.querySelector('p-segmented-control');
  const debugElement = document.querySelector('p-text');

  segmentedControl.addEventListener('update', (e) => {
    const { value } = e.detail;
    segmentedControl.value = value;
    debugElement.innerText = `Current value: ${value}`;
  });
</script>
</body>
</html>
With Labels Additional meta information can be displayed by setting a label on each child.
Option 1Option 2Option 3Option 4Option 5
Open in Stackblitz
<!doctype html>
<html lang="en" class="auto">
<head>
  <title></title>
</head>
<body class="bg-base">

<p-segmented-control value="1">
  <p-segmented-control-item value="1" label="Label">
    Option 1
  </p-segmented-control-item>
  <p-segmented-control-item value="2" label="Label">
    Option 2
  </p-segmented-control-item>
  <p-segmented-control-item value="3" label="Label">
    Option 3
  </p-segmented-control-item>
  <p-segmented-control-item value="4" label="Label" disabled="true">
    Option 4
  </p-segmented-control-item>
  <p-segmented-control-item value="5" label="Label">
    Option 5
  </p-segmented-control-item>
</p-segmented-control>
<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)DirectionChanges the direction of HTML elements, mostly used on<html> tag to support languages which are read from right to left like e.g. Arabic.LTR (left-to-right)RTL (right-to-left)AutoText ZoomChanges the text size and values with unit rem or em relatively. This setting can be defined in browser settings for any website or by an application itself on<html> tag. To achieve WCAG 2.2 AA compliance it's obligatory to support text zoom up to at least 200%.100%130%150%200%