@porsche-design-system/components-react 4.5.0 → 4.6.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/bin/pds-skill.js +259 -0
  3. package/esm/lib/components/button.wrapper.d.ts +2 -2
  4. package/esm/lib/components/link.wrapper.d.ts +2 -2
  5. package/package.json +4 -3
  6. package/skill/SKILL.md +136 -0
  7. package/skill/references/components/p-accordion/examples/Default.tsx +24 -0
  8. package/skill/references/components/p-accordion/examples/InteractiveElementsInSummary.tsx +28 -0
  9. package/skill/references/components/p-accordion/examples/StickySummary.tsx +24 -0
  10. package/skill/references/components/p-accordion/p-accordion.md +95 -0
  11. package/skill/references/components/p-ai-tag/examples/Default.tsx +10 -0
  12. package/skill/references/components/p-ai-tag/examples/WithinCheckbox.tsx +30 -0
  13. package/skill/references/components/p-ai-tag/examples/WithinFormLabel.tsx +37 -0
  14. package/skill/references/components/p-ai-tag/examples/WithinImage.tsx +13 -0
  15. package/skill/references/components/p-ai-tag/examples/WithinInputSearch.tsx +12 -0
  16. package/skill/references/components/p-ai-tag/examples/WithinRadioGroup.tsx +29 -0
  17. package/skill/references/components/p-ai-tag/examples/WithinTable.tsx +91 -0
  18. package/skill/references/components/p-ai-tag/examples/WithinText.tsx +14 -0
  19. package/skill/references/components/p-ai-tag/p-ai-tag.md +47 -0
  20. package/skill/references/components/p-banner/examples/Customization.tsx +35 -0
  21. package/skill/references/components/p-banner/examples/Default.tsx +24 -0
  22. package/skill/references/components/p-banner/p-banner.md +92 -0
  23. package/skill/references/components/p-button/examples/Default.tsx +12 -0
  24. package/skill/references/components/p-button/examples/Form.tsx +28 -0
  25. package/skill/references/components/p-button/examples/FormAttribute.tsx +31 -0
  26. package/skill/references/components/p-button/p-button.md +118 -0
  27. package/skill/references/components/p-button-pure/examples/CustomClickableArea.tsx +12 -0
  28. package/skill/references/components/p-button-pure/examples/Default.tsx +12 -0
  29. package/skill/references/components/p-button-pure/examples/Form.tsx +28 -0
  30. package/skill/references/components/p-button-pure/examples/FormAttribute.tsx +32 -0
  31. package/skill/references/components/p-button-pure/p-button-pure.md +118 -0
  32. package/skill/references/components/p-button-tile/examples/ColorScheme.tsx +15 -0
  33. package/skill/references/components/p-button-tile/examples/Default.tsx +18 -0
  34. package/skill/references/components/p-button-tile/examples/FooterSlot.tsx +29 -0
  35. package/skill/references/components/p-button-tile/examples/Hyphens.tsx +33 -0
  36. package/skill/references/components/p-button-tile/examples/UiBehaviour.tsx +41 -0
  37. package/skill/references/components/p-button-tile/p-button-tile.md +115 -0
  38. package/skill/references/components/p-canvas/examples/Default.tsx +10 -0
  39. package/skill/references/components/p-canvas/p-canvas.md +91 -0
  40. package/skill/references/components/p-carousel/examples/Default.tsx +23 -0
  41. package/skill/references/components/p-carousel/examples/DynamicSlides.tsx +32 -0
  42. package/skill/references/components/p-carousel/examples/FlexibleWidths.tsx +29 -0
  43. package/skill/references/components/p-carousel/examples/FocusOnCenterSlide.tsx +56 -0
  44. package/skill/references/components/p-carousel/examples/Intl.tsx +20 -0
  45. package/skill/references/components/p-carousel/examples/JumpToSlide.tsx +42 -0
  46. package/skill/references/components/p-carousel/p-carousel.md +142 -0
  47. package/skill/references/components/p-checkbox/examples/Default.tsx +10 -0
  48. package/skill/references/components/p-checkbox/examples/Form.tsx +45 -0
  49. package/skill/references/components/p-checkbox/examples/Indeterminate.tsx +13 -0
  50. package/skill/references/components/p-checkbox/examples/Slots.tsx +54 -0
  51. package/skill/references/components/p-checkbox/examples/WrappedLabel.tsx +24 -0
  52. package/skill/references/components/p-checkbox/p-checkbox.md +122 -0
  53. package/skill/references/components/p-crest/examples/CustomClickableArea.tsx +10 -0
  54. package/skill/references/components/p-crest/examples/Default.tsx +10 -0
  55. package/skill/references/components/p-crest/examples/Link.tsx +10 -0
  56. package/skill/references/components/p-crest/p-crest.md +65 -0
  57. package/skill/references/components/p-display/examples/Color.tsx +12 -0
  58. package/skill/references/components/p-display/examples/Default.tsx +12 -0
  59. package/skill/references/components/p-display/examples/Semantics.tsx +18 -0
  60. package/skill/references/components/p-display/examples/Size.tsx +12 -0
  61. package/skill/references/components/p-display/examples/SizeResponsive.tsx +12 -0
  62. package/skill/references/components/p-display/p-display.md +78 -0
  63. package/skill/references/components/p-divider/examples/Default.tsx +10 -0
  64. package/skill/references/components/p-divider/examples/Responsive.tsx +12 -0
  65. package/skill/references/components/p-divider/examples/Vertical.tsx +12 -0
  66. package/skill/references/components/p-divider/p-divider.md +49 -0
  67. package/skill/references/components/p-drilldown/examples/CustomContent.tsx +164 -0
  68. package/skill/references/components/p-drilldown/examples/Default.tsx +117 -0
  69. package/skill/references/components/p-drilldown/p-drilldown.md +168 -0
  70. package/skill/references/components/p-fieldset/examples/Default.tsx +12 -0
  71. package/skill/references/components/p-fieldset/examples/Required.tsx +13 -0
  72. package/skill/references/components/p-fieldset/examples/SlottedLabel.tsx +15 -0
  73. package/skill/references/components/p-fieldset/examples/SlottedMessage.tsx +15 -0
  74. package/skill/references/components/p-fieldset/p-fieldset.md +88 -0
  75. package/skill/references/components/p-flag/examples/Default.tsx +10 -0
  76. package/skill/references/components/p-flag/examples/ResponsiveSize.tsx +10 -0
  77. package/skill/references/components/p-flag/examples/Size.tsx +13 -0
  78. package/skill/references/components/p-flag/examples/SizeCssVar.tsx +10 -0
  79. package/skill/references/components/p-flag/p-flag.md +68 -0
  80. package/skill/references/components/p-flyout/examples/CustomStyling.tsx +45 -0
  81. package/skill/references/components/p-flyout/examples/Default.tsx +42 -0
  82. package/skill/references/components/p-flyout/examples/Form.tsx +54 -0
  83. package/skill/references/components/p-flyout/examples/StickyTop.tsx +42 -0
  84. package/skill/references/components/p-flyout/p-flyout.md +128 -0
  85. package/skill/references/components/p-heading/examples/Color.tsx +12 -0
  86. package/skill/references/components/p-heading/examples/Default.tsx +12 -0
  87. package/skill/references/components/p-heading/examples/Semantics.tsx +18 -0
  88. package/skill/references/components/p-heading/p-heading.md +78 -0
  89. package/skill/references/components/p-icon/examples/Color.tsx +13 -0
  90. package/skill/references/components/p-icon/examples/ColorCssVar.tsx +10 -0
  91. package/skill/references/components/p-icon/examples/Custom.tsx +10 -0
  92. package/skill/references/components/p-icon/examples/Default.tsx +10 -0
  93. package/skill/references/components/p-icon/examples/Overview.tsx +588 -0
  94. package/skill/references/components/p-icon/examples/ResponsiveSize.tsx +10 -0
  95. package/skill/references/components/p-icon/examples/Size.tsx +13 -0
  96. package/skill/references/components/p-icon/examples/SizeCssVar.tsx +10 -0
  97. package/skill/references/components/p-icon/p-icon.md +88 -0
  98. package/skill/references/components/p-inline-notification/examples/ActionButton.tsx +25 -0
  99. package/skill/references/components/p-inline-notification/examples/Default.tsx +10 -0
  100. package/skill/references/components/p-inline-notification/examples/EventHandling.tsx +25 -0
  101. package/skill/references/components/p-inline-notification/p-inline-notification.md +74 -0
  102. package/skill/references/components/p-input-date/examples/Default.tsx +10 -0
  103. package/skill/references/components/p-input-date/examples/Form.tsx +45 -0
  104. package/skill/references/components/p-input-date/examples/Slots.tsx +41 -0
  105. package/skill/references/components/p-input-date/p-input-date.md +142 -0
  106. package/skill/references/components/p-input-email/examples/Default.tsx +10 -0
  107. package/skill/references/components/p-input-email/examples/Form.tsx +51 -0
  108. package/skill/references/components/p-input-email/examples/Slots.tsx +41 -0
  109. package/skill/references/components/p-input-email/p-input-email.md +146 -0
  110. package/skill/references/components/p-input-month/examples/Default.tsx +10 -0
  111. package/skill/references/components/p-input-month/examples/Form.tsx +45 -0
  112. package/skill/references/components/p-input-month/examples/Slots.tsx +41 -0
  113. package/skill/references/components/p-input-month/p-input-month.md +142 -0
  114. package/skill/references/components/p-input-number/examples/Default.tsx +10 -0
  115. package/skill/references/components/p-input-number/examples/Form.tsx +51 -0
  116. package/skill/references/components/p-input-number/examples/Slots.tsx +41 -0
  117. package/skill/references/components/p-input-number/p-input-number.md +150 -0
  118. package/skill/references/components/p-input-password/examples/Default.tsx +10 -0
  119. package/skill/references/components/p-input-password/examples/Form.tsx +51 -0
  120. package/skill/references/components/p-input-password/examples/Slots.tsx +39 -0
  121. package/skill/references/components/p-input-password/examples/Toggle.tsx +10 -0
  122. package/skill/references/components/p-input-password/p-input-password.md +145 -0
  123. package/skill/references/components/p-input-search/examples/AriaCombobox.tsx +35 -0
  124. package/skill/references/components/p-input-search/examples/Default.tsx +10 -0
  125. package/skill/references/components/p-input-search/examples/Form.tsx +52 -0
  126. package/skill/references/components/p-input-search/examples/Slots.tsx +41 -0
  127. package/skill/references/components/p-input-search/p-input-search.md +182 -0
  128. package/skill/references/components/p-input-tel/examples/Default.tsx +10 -0
  129. package/skill/references/components/p-input-tel/examples/Form.tsx +45 -0
  130. package/skill/references/components/p-input-tel/examples/Slots.tsx +41 -0
  131. package/skill/references/components/p-input-tel/p-input-tel.md +145 -0
  132. package/skill/references/components/p-input-text/examples/Controlled.tsx +36 -0
  133. package/skill/references/components/p-input-text/examples/Default.tsx +10 -0
  134. package/skill/references/components/p-input-text/examples/Form.tsx +45 -0
  135. package/skill/references/components/p-input-text/examples/Slots.tsx +41 -0
  136. package/skill/references/components/p-input-text/p-input-text.md +150 -0
  137. package/skill/references/components/p-input-time/examples/Default.tsx +10 -0
  138. package/skill/references/components/p-input-time/examples/Form.tsx +45 -0
  139. package/skill/references/components/p-input-time/examples/Slots.tsx +41 -0
  140. package/skill/references/components/p-input-time/p-input-time.md +144 -0
  141. package/skill/references/components/p-input-url/examples/Default.tsx +10 -0
  142. package/skill/references/components/p-input-url/examples/Form.tsx +45 -0
  143. package/skill/references/components/p-input-url/examples/Slots.tsx +41 -0
  144. package/skill/references/components/p-input-url/p-input-url.md +145 -0
  145. package/skill/references/components/p-input-week/examples/Default.tsx +10 -0
  146. package/skill/references/components/p-input-week/examples/Form.tsx +45 -0
  147. package/skill/references/components/p-input-week/examples/Slots.tsx +41 -0
  148. package/skill/references/components/p-input-week/p-input-week.md +142 -0
  149. package/skill/references/components/p-link/examples/Default.tsx +12 -0
  150. package/skill/references/components/p-link/examples/FrameworkRouting.tsx +14 -0
  151. package/skill/references/components/p-link/examples/Icon.tsx +17 -0
  152. package/skill/references/components/p-link/p-link.md +101 -0
  153. package/skill/references/components/p-link-pure/examples/CustomClickableArea.tsx +12 -0
  154. package/skill/references/components/p-link-pure/examples/Default.tsx +12 -0
  155. package/skill/references/components/p-link-pure/examples/FrameworkRouting.tsx +14 -0
  156. package/skill/references/components/p-link-pure/examples/Icon.tsx +17 -0
  157. package/skill/references/components/p-link-pure/p-link-pure.md +110 -0
  158. package/skill/references/components/p-link-tile/examples/ColorScheme.tsx +15 -0
  159. package/skill/references/components/p-link-tile/examples/Default.tsx +18 -0
  160. package/skill/references/components/p-link-tile/examples/FooterSlot.tsx +29 -0
  161. package/skill/references/components/p-link-tile/examples/Hyphens.tsx +34 -0
  162. package/skill/references/components/p-link-tile/examples/UiBehaviour.tsx +41 -0
  163. package/skill/references/components/p-link-tile/examples/WithVideo.tsx +15 -0
  164. package/skill/references/components/p-link-tile/p-link-tile.md +105 -0
  165. package/skill/references/components/p-link-tile-product/examples/Default.tsx +22 -0
  166. package/skill/references/components/p-link-tile-product/examples/FrameworkRouting.tsx +25 -0
  167. package/skill/references/components/p-link-tile-product/p-link-tile-product.md +93 -0
  168. package/skill/references/components/p-modal/examples/AlertDialog.tsx +39 -0
  169. package/skill/references/components/p-modal/examples/CustomStyling.tsx +26 -0
  170. package/skill/references/components/p-modal/examples/Default.tsx +39 -0
  171. package/skill/references/components/p-modal/examples/Scrollable.tsx +43 -0
  172. package/skill/references/components/p-modal/p-modal.md +135 -0
  173. package/skill/references/components/p-model-signature/examples/CustomStyling.tsx +14 -0
  174. package/skill/references/components/p-model-signature/examples/Default.tsx +10 -0
  175. package/skill/references/components/p-model-signature/examples/MaskBlendMode.tsx +32 -0
  176. package/skill/references/components/p-model-signature/examples/MaskImage.tsx +12 -0
  177. package/skill/references/components/p-model-signature/examples/MaskVideo.tsx +12 -0
  178. package/skill/references/components/p-model-signature/examples/SafeZone.tsx +60 -0
  179. package/skill/references/components/p-model-signature/p-model-signature.md +62 -0
  180. package/skill/references/components/p-multi-select/examples/AsyncFilter.tsx +136 -0
  181. package/skill/references/components/p-multi-select/examples/Default.tsx +29 -0
  182. package/skill/references/components/p-multi-select/examples/Form.tsx +53 -0
  183. package/skill/references/components/p-multi-select/examples/Optgroups.tsx +42 -0
  184. package/skill/references/components/p-multi-select/examples/SelectedSlot.tsx +94 -0
  185. package/skill/references/components/p-multi-select/examples/SetValue.tsx +80 -0
  186. package/skill/references/components/p-multi-select/examples/Slots.tsx +48 -0
  187. package/skill/references/components/p-multi-select/p-multi-select.md +197 -0
  188. package/skill/references/components/p-pagination/examples/Default.tsx +10 -0
  189. package/skill/references/components/p-pagination/p-pagination.md +83 -0
  190. package/skill/references/components/p-pin-code/examples/CopyPaste.tsx +10 -0
  191. package/skill/references/components/p-pin-code/examples/Default.tsx +10 -0
  192. package/skill/references/components/p-pin-code/examples/Form.tsx +45 -0
  193. package/skill/references/components/p-pin-code/examples/Slots.tsx +39 -0
  194. package/skill/references/components/p-pin-code/p-pin-code.md +109 -0
  195. package/skill/references/components/p-popover/examples/Default.tsx +14 -0
  196. package/skill/references/components/p-popover/examples/SlottedButton.tsx +15 -0
  197. package/skill/references/components/p-popover/p-popover.md +116 -0
  198. package/skill/references/components/p-radio-group/examples/Default.tsx +17 -0
  199. package/skill/references/components/p-radio-group/examples/Form.tsx +53 -0
  200. package/skill/references/components/p-radio-group/examples/Slots.tsx +69 -0
  201. package/skill/references/components/p-radio-group/p-radio-group.md +157 -0
  202. package/skill/references/components/p-scroller/examples/Default.tsx +51 -0
  203. package/skill/references/components/p-scroller/examples/Height.tsx +26 -0
  204. package/skill/references/components/p-scroller/examples/ScrollToPosition.tsx +58 -0
  205. package/skill/references/components/p-scroller/p-scroller.md +93 -0
  206. package/skill/references/components/p-segmented-control/examples/Default.tsx +26 -0
  207. package/skill/references/components/p-segmented-control/examples/Form.tsx +52 -0
  208. package/skill/references/components/p-segmented-control/examples/Slots.tsx +54 -0
  209. package/skill/references/components/p-segmented-control/examples/WithLabels.tsx +26 -0
  210. package/skill/references/components/p-segmented-control/p-segmented-control.md +162 -0
  211. package/skill/references/components/p-select/examples/AsyncFilter.tsx +136 -0
  212. package/skill/references/components/p-select/examples/Default.tsx +29 -0
  213. package/skill/references/components/p-select/examples/Form.tsx +53 -0
  214. package/skill/references/components/p-select/examples/Optgroups.tsx +42 -0
  215. package/skill/references/components/p-select/examples/Required.tsx +48 -0
  216. package/skill/references/components/p-select/examples/SelectedSlot.tsx +124 -0
  217. package/skill/references/components/p-select/examples/SetValue.tsx +80 -0
  218. package/skill/references/components/p-select/examples/Slots.tsx +48 -0
  219. package/skill/references/components/p-select/examples/SlottedImages.tsx +35 -0
  220. package/skill/references/components/p-select/p-select.md +194 -0
  221. package/skill/references/components/p-sheet/examples/Default.tsx +31 -0
  222. package/skill/references/components/p-sheet/p-sheet.md +121 -0
  223. package/skill/references/components/p-spinner/examples/Color.tsx +13 -0
  224. package/skill/references/components/p-spinner/examples/ColorCssVar.tsx +10 -0
  225. package/skill/references/components/p-spinner/examples/Default.tsx +10 -0
  226. package/skill/references/components/p-spinner/examples/ResponsiveSize.tsx +10 -0
  227. package/skill/references/components/p-spinner/examples/Size.tsx +13 -0
  228. package/skill/references/components/p-spinner/examples/SizeCssVar.tsx +10 -0
  229. package/skill/references/components/p-spinner/p-spinner.md +96 -0
  230. package/skill/references/components/p-stepper-horizontal/examples/Default.tsx +23 -0
  231. package/skill/references/components/p-stepper-horizontal/examples/FrameworkImplementation.tsx +100 -0
  232. package/skill/references/components/p-stepper-horizontal/p-stepper-horizontal.md +109 -0
  233. package/skill/references/components/p-switch/examples/Default.tsx +19 -0
  234. package/skill/references/components/p-switch/p-switch.md +103 -0
  235. package/skill/references/components/p-table/examples/Advanced.tsx +186 -0
  236. package/skill/references/components/p-table/examples/CaptionProperty.tsx +37 -0
  237. package/skill/references/components/p-table/examples/CaptionSlot.tsx +40 -0
  238. package/skill/references/components/p-table/examples/Default.tsx +117 -0
  239. package/skill/references/components/p-table/examples/HideLabel.tsx +37 -0
  240. package/skill/references/components/p-table/examples/LayoutFixed.tsx +50 -0
  241. package/skill/references/components/p-table/examples/Sorting.tsx +86 -0
  242. package/skill/references/components/p-table/p-table.md +189 -0
  243. package/skill/references/components/p-tabs/examples/ActiveTab.tsx +26 -0
  244. package/skill/references/components/p-tabs/examples/Default.tsx +26 -0
  245. package/skill/references/components/p-tabs/examples/Gradient.tsx +111 -0
  246. package/skill/references/components/p-tabs/examples/Labelling.tsx +26 -0
  247. package/skill/references/components/p-tabs/p-tabs.md +136 -0
  248. package/skill/references/components/p-tabs-bar/examples/Default.tsx +27 -0
  249. package/skill/references/components/p-tabs-bar/examples/Gradient.tsx +78 -0
  250. package/skill/references/components/p-tabs-bar/examples/Labelling.tsx +27 -0
  251. package/skill/references/components/p-tabs-bar/examples/Links.tsx +20 -0
  252. package/skill/references/components/p-tabs-bar/p-tabs-bar.md +181 -0
  253. package/skill/references/components/p-tag/examples/Default.tsx +12 -0
  254. package/skill/references/components/p-tag/examples/Multiline.tsx +14 -0
  255. package/skill/references/components/p-tag/examples/SlottedButton.tsx +41 -0
  256. package/skill/references/components/p-tag/examples/SlottedLink.tsx +41 -0
  257. package/skill/references/components/p-tag/p-tag.md +66 -0
  258. package/skill/references/components/p-tag-dismissible/examples/Default.tsx +12 -0
  259. package/skill/references/components/p-tag-dismissible/p-tag-dismissible.md +75 -0
  260. package/skill/references/components/p-text/examples/Default.tsx +12 -0
  261. package/skill/references/components/p-text/examples/Semantics.tsx +18 -0
  262. package/skill/references/components/p-text/examples/Size.tsx +12 -0
  263. package/skill/references/components/p-text/examples/SizeResponsive.tsx +12 -0
  264. package/skill/references/components/p-text/p-text.md +68 -0
  265. package/skill/references/components/p-text-list/examples/Default.tsx +28 -0
  266. package/skill/references/components/p-text-list/p-text-list.md +68 -0
  267. package/skill/references/components/p-textarea/examples/Default.tsx +10 -0
  268. package/skill/references/components/p-textarea/examples/Form.tsx +45 -0
  269. package/skill/references/components/p-textarea/examples/Slots.tsx +39 -0
  270. package/skill/references/components/p-textarea/p-textarea.md +122 -0
  271. package/skill/references/components/p-toast/examples/Default.tsx +22 -0
  272. package/skill/references/components/p-toast/p-toast.md +61 -0
  273. package/skill/references/components/p-wordmark/examples/CustomClickableArea.tsx +10 -0
  274. package/skill/references/components/p-wordmark/examples/Default.tsx +10 -0
  275. package/skill/references/components/p-wordmark/examples/Size.tsx +10 -0
  276. package/skill/references/components/p-wordmark/p-wordmark.md +66 -0
  277. package/skill/references/icons.md +5 -0
  278. package/skill/references/styles/emotion.md +439 -0
  279. package/skill/references/styles/scss.md +402 -0
  280. package/skill/references/styles/tailwindcss.md +356 -0
  281. package/skill/references/styles/vanilla-extract.md +444 -0
  282. package/skill/references/stylesheets.md +331 -0
  283. package/skill/references/tokens.md +323 -0
  284. package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +1 -1
  285. package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +1 -1
  286. package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +1 -1
  287. package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +1 -1
  288. package/ssr/esm/lib/components/button.wrapper.d.ts +2 -2
  289. package/ssr/esm/lib/components/link.wrapper.d.ts +2 -2
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { PSegmentedControl, PSegmentedControlItem } from '@porsche-design-system/components-react';
3
+
4
+ export const Example = () => {
5
+ return (
6
+ <>
7
+ <PSegmentedControl label="Some Label" description="Some description">
8
+ <PSegmentedControlItem value="1">
9
+ Option 1
10
+ </PSegmentedControlItem>
11
+ <PSegmentedControlItem value="2">
12
+ Option 2
13
+ </PSegmentedControlItem>
14
+ <PSegmentedControlItem value="3">
15
+ Option 3
16
+ </PSegmentedControlItem>
17
+ <PSegmentedControlItem value="4">
18
+ Option 4
19
+ </PSegmentedControlItem>
20
+ <PSegmentedControlItem value="5">
21
+ Option 5
22
+ </PSegmentedControlItem>
23
+ </PSegmentedControl>
24
+ </>
25
+ )
26
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import {
3
+ PButton,
4
+ PSegmentedControl,
5
+ PSegmentedControlItem,
6
+ type PSegmentedControlProps,
7
+ PText,
8
+ type SegmentedControlChangeEventDetail,
9
+ } from '@porsche-design-system/components-react';
10
+ import { FormEvent, useState } from 'react';
11
+
12
+ export const Example = () => {
13
+ const [form, setForm] = useState({ mySegmentedControl: undefined });
14
+ const [lastSubmittedData, setLastSubmittedData] = useState<any>();
15
+
16
+ const onChange = (e: CustomEvent<SegmentedControlChangeEventDetail>) => {
17
+ const { name, value } = e.target as HTMLElement & PSegmentedControlProps;
18
+ setForm((prev) => ({
19
+ ...prev,
20
+ [name]: value,
21
+ }));
22
+ };
23
+
24
+ const onSubmit = (e: FormEvent<HTMLFormElement>) => {
25
+ e.preventDefault();
26
+ setLastSubmittedData(JSON.stringify(form));
27
+ };
28
+
29
+ const onReset = (e: FormEvent<HTMLFormElement>) => {
30
+ e.preventDefault();
31
+ setForm({ mySegmentedControl: undefined });
32
+ };
33
+
34
+ return (
35
+ <>
36
+ <form onSubmit={onSubmit} onReset={onReset} className="flex flex-col gap-fluid-sm">
37
+ <PSegmentedControl name="mySegmentedControl" value={form.mySegmentedControl} onChange={onChange}>
38
+ <PSegmentedControlItem value={1}>Option 1</PSegmentedControlItem>
39
+ <PSegmentedControlItem value={2}>Option 2</PSegmentedControlItem>
40
+ <PSegmentedControlItem value={3}>Option 3</PSegmentedControlItem>
41
+ <PSegmentedControlItem value={4}>Option 4</PSegmentedControlItem>
42
+ <PSegmentedControlItem value={5}>Option 5</PSegmentedControlItem>
43
+ </PSegmentedControl>
44
+ <div className="flex gap-fluid-sm">
45
+ <PButton type="submit">Submit</PButton>
46
+ <PButton type="reset">Reset</PButton>
47
+ </div>
48
+ <PText>Last submitted data: {lastSubmittedData}</PText>
49
+ </form>
50
+ </>
51
+ );
52
+ };
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { PPopover, PSegmentedControl, PSegmentedControlItem } from '@porsche-design-system/components-react';
3
+
4
+ export const Example = () => {
5
+ return (
6
+ <>
7
+ <PSegmentedControl state="error">
8
+ <span slot="label" id="some-label-id">
9
+ Some label with a
10
+ <a href="https://designsystem.porsche.com" className="underline">
11
+ link
12
+ </a>
13
+ and a "label-after" slot.
14
+ </span>
15
+ <PPopover slot="label-after">
16
+ Some Popover content with a
17
+ <a href="https://designsystem.porsche.com" className="underline">
18
+ link
19
+ </a>
20
+ .
21
+ </PPopover>
22
+ <span slot="description" id="some-description-id">
23
+ Some description with a
24
+ <a href="https://designsystem.porsche.com" className="underline">
25
+ link
26
+ </a>
27
+ .
28
+ </span>
29
+ <span slot="message" id="some-message-id">
30
+ Some error message with a
31
+ <a href="https://designsystem.porsche.com" className="underline">
32
+ link
33
+ </a>
34
+ .
35
+ </span>
36
+ <PSegmentedControlItem value="1">
37
+ Option 1
38
+ </PSegmentedControlItem>
39
+ <PSegmentedControlItem value="2">
40
+ Option 2
41
+ </PSegmentedControlItem>
42
+ <PSegmentedControlItem value="3">
43
+ Option 3
44
+ </PSegmentedControlItem>
45
+ <PSegmentedControlItem value="4">
46
+ Option 4
47
+ </PSegmentedControlItem>
48
+ <PSegmentedControlItem value="5">
49
+ Option 5
50
+ </PSegmentedControlItem>
51
+ </PSegmentedControl>
52
+ </>
53
+ )
54
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { PSegmentedControl, PSegmentedControlItem } from '@porsche-design-system/components-react';
3
+
4
+ export const Example = () => {
5
+ return (
6
+ <>
7
+ <PSegmentedControl value="1">
8
+ <PSegmentedControlItem value="1" label="Label">
9
+ Option 1
10
+ </PSegmentedControlItem>
11
+ <PSegmentedControlItem value="2" label="Label">
12
+ Option 2
13
+ </PSegmentedControlItem>
14
+ <PSegmentedControlItem value="3" label="Label">
15
+ Option 3
16
+ </PSegmentedControlItem>
17
+ <PSegmentedControlItem value="4" label="Label" disabled={true}>
18
+ Option 4
19
+ </PSegmentedControlItem>
20
+ <PSegmentedControlItem value="5" label="Label">
21
+ Option 5
22
+ </PSegmentedControlItem>
23
+ </PSegmentedControl>
24
+ </>
25
+ )
26
+ }
@@ -0,0 +1,162 @@
1
+ # p-segmented-control
2
+
3
+ The `p-segmented-control` component is similar to the native `select` element while showing all available options right away.
4
+
5
+ It even behaves like a `select` where it can be controlled by setting the current value. However, it is not required and you could purely rely on the change event.
6
+
7
+ By default the `p-segmented-control` displays all options in **equal** size based on its largest option. If the `no-wrap` property is set to `true`, the items will be rendered inline (shrinked to their initial size) with an optional scroller.
8
+
9
+ Each option needs to be rendered by using a `p-segmented-control-item` child component where the `value` property is **mandatory** in order to emit a useful change event.
10
+
11
+ ## Usage
12
+
13
+ ### Do:
14
+
15
+ - Use to present a set of selectable options at once.
16
+ - Use it for selecting from 2-5 short, consistent options.
17
+ - Use them over other selection controls to reduce cognitive load.
18
+ - Pair options with icons to improve visual recognition.
19
+ - Use icons only when the context meaning is really clear.
20
+ - Use preselection when the result is visible by default.
21
+ - Use with no selection when a selection by the user is necessary to show the result.
22
+ - Use it with a short indication for the unit (such as km, €, %, or $) when possible.
23
+ - Use for horizontal and/or vertical display of options.
24
+
25
+ ### Don't:
26
+
27
+ - Don't use it to filter or navigate content (use [Tabs](../p-tabs/p-tabs.md) instead).
28
+ - Don't use it for more than 5 options (use the [Select](../p-select/p-select.md) component).
29
+ - Don't use it with mixed values (use [Radio Group](../p-radio-group/p-radio-group.md) or [Select](../p-select/p-select.md) instead).
30
+ - Don't exceed maximum width so the values turn multiline.
31
+
32
+ ---
33
+
34
+ ## Related components
35
+
36
+ - [Select](../p-select/p-select.md)
37
+ - [Radio Button](../p-radio-group/p-radio-group.md)
38
+ - [Tabs](../p-tabs/p-tabs.md)
39
+
40
+ ## Accessibility support
41
+
42
+ ### Keyboard
43
+
44
+ | Key / state | Function |
45
+ | --- | --- |
46
+ | `Tab`, `Shift-Tab` | Moves focus to the next (or previous) focusable element. |
47
+ | `Space`, `Enter` | Activates the control. |
48
+
49
+ ### ARIA enhancements
50
+
51
+ #### External **ARIA** provided by the `aria` property:
52
+
53
+ | ARIA | Usage |
54
+ | --- | --- |
55
+ | `aria-label="STRING"` | Defines a string value that labels the control item itself. |
56
+
57
+ #### Internal **ARIA** that is managed by the component:
58
+
59
+ | ARIA | Usage |
60
+ | --- | --- |
61
+ | `role="group"` | Identifies a set of user interface objects. |
62
+ | `aria-pressed="BOOLEAN"` | Provides the current state of the control. |
63
+ | `role="status"`, `role="alert"` | When `message` and `state` or `loading` prop change, the status message is announced. |
64
+ | `aria-hidden="true"` | If `required` attribute is set, the visible asterisk indicator is hidden from assistive technologies. |
65
+ | `aria-invalid="true"` | If `error` state is set. |
66
+ | `aria-required="true"` | Indicates if the element is required. |
67
+ | `aria-description="STRING"` | Provides additional content for states. |
68
+
69
+ ## Development considerations
70
+
71
+ ### Labelling
72
+
73
+ Provide a descriptive `label` on the wrapper component to give context for the group of options. If a more detailed label is needed for each **control item**, use the `aria` property on the control item itself, e.g.: `<p-segmented-control-item value="xs" aria="{ 'aria-label': 'Size x-small' }">XS</p-segmented-control-item>`.
74
+
75
+ If an **icon only** is used, it is mandatory to also provide an accessible name through the `aria` property of the control item.
76
+
77
+ ### Disabled state
78
+
79
+ In general, avoid using the `disabled` state. Disabled elements are no longer focusable and may be missed by screen reader users. They can also confuse sighted users if the reason they are disabled is not made clear.
80
+
81
+ ### Common do's and don'ts
82
+
83
+ - **Do** provide a clear group `label` that describes the choice being made.
84
+ - **Do** pass item-level ARIA through the `aria` prop on `p-segmented-control-item`, especially for icon-only items.
85
+ - **Do** use the component state/message API so validation and status changes are announced.
86
+ - **Don't** add native `aria-*` attributes directly on the component host.
87
+ - **Don't** use `hide-label` without an accessible name.
88
+
89
+ ## API
90
+
91
+ ### Properties
92
+
93
+ | Property | Type | Default | Description |
94
+ | --- | --- | --- | --- |
95
+ | `columns` | `'auto'` `1` `2` `3` `4` `5` `6` `7` `8` `9` `10` `11` `12` `13` `14` `15` `16` `17` `18` `19` `20` `21` `22` `23` `24` `25`<br>`BreakpointCustomizable<SegmentedControlColumns>` | `'auto'` | Sets the number of equal-width columns for the item layout. Use `auto` to distribute items based on their content width. Supports responsive breakpoint values. |
96
+ | `compact` | `boolean` | `false` | Reduces the item height and spacing for use in dense layouts where vertical space is limited. |
97
+ | `description` | `string` | `''` | Sets a supplementary description displayed below the label to give users additional context about the segmented control. |
98
+ | `disabled` | `boolean` | `false` | Prevents user interaction with all items in the segmented control and excludes the value from form submissions. |
99
+ | `form` | `string` | `undefined` | Associates the segmented control with a form element by its ID when it is not a direct descendant of that form. |
100
+ | `hideLabel` | `boolean`<br>`BreakpointCustomizable<boolean>` | `false` | Hides the visible label while keeping it accessible to screen readers. Supports responsive breakpoint values. |
101
+ | `label` | `string` | `''` | Sets the visible label text displayed above the segmented control to describe the group of options. |
102
+ | `message` | `string` | `''` | Sets the validation feedback message displayed below the segmented control when `state` is `success` or `error`. |
103
+ | `name` | `string` | `undefined` | Sets the name of the control submitted with the form data to identify the selected value on the server. |
104
+ | `noWrap` | `boolean` | `false` | Prevents items from wrapping to new rows and renders them in a single horizontally scrollable row instead. |
105
+ | `required` | `boolean` | `false` | Marks the segmented control as required so the form cannot be submitted until one option is selected. |
106
+ | `state` | `'none'` `'error'` `'success'` | `'none'` | Sets the validation state of the segmented control, controlling its visual appearance and feedback message style (`none`, `success`, `error`). |
107
+ | `value` | `string | number` | `undefined` | Sets the currently selected item's value and pre-selects the matching option when the component renders. |
108
+
109
+ ### Events
110
+
111
+ | Event | Type | Description |
112
+ | --- | --- | --- |
113
+ | `blur` | `CustomEvent<void>` | Emitted when the segmented control loses focus, useful for triggering validation on blur. |
114
+ | `change` | `CustomEvent<SegmentedControlChangeEventDetail>`<br>`{ value: string | number }` | Emitted when the user selects a different item, carrying the new value in the event detail. |
115
+
116
+ ### Controlled properties
117
+
118
+ - `value` — a controlled prop, but the component also updates it internally. Listen for the `change` event to observe changes; you do not have to write the value back.
119
+
120
+ ### Slots
121
+
122
+ | Slot | Required | Allowed tag names | Description |
123
+ | --- | --- | --- | --- |
124
+ | `label` | no | — | Shows a label. Only [phrasing content](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) is allowed. |
125
+ | `label-after` | no | — | Places additional content after the label text (for content that should not be part of the label, e.g. external links or `p-popover`). |
126
+ | `description` | no | — | Shows a description. Only [phrasing content](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) is allowed. |
127
+ | _(default)_ | no | — | Default slot for the `p-segmented-control-item` tags. |
128
+ | `message` | no | — | Shows a state message. Only [phrasing content](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content) is allowed. |
129
+
130
+ ## Sub-components
131
+
132
+ These tags are only valid inside the parent(s) listed under each one — often this component, but some are shared and list a different parent (e.g. a tag documented here via a common ancestor). Their APIs come from the same authoritative `component-meta` as the parent above.
133
+
134
+ ### `p-segmented-control-item`
135
+
136
+ Allowed parent: `p-segmented-control`.
137
+
138
+ #### Properties
139
+
140
+ | Property | Type | Default | Description |
141
+ | --- | --- | --- | --- |
142
+ | `aria` | `SegmentedControlItemAriaAttribute` | `undefined` | Sets ARIA attributes on the item's button element to improve accessibility for screen readers. |
143
+ | `disabled` | `boolean` | `false` | Prevents this item from being selected and visually dims it; the parent's value will not change to this item's value. |
144
+ | `icon` | `''`<br>one of 290 icon names — see [icon names](references/icons.md) | `undefined` | Sets an icon rendered inside the item button using an icon name from the PDS icon library. |
145
+ | `iconSource` | `string` | `undefined` | Sets a URL to a custom SVG icon for the item button, overriding the built-in icon set. |
146
+ | `label` | `string` | `undefined` | Sets a visible text label rendered inside the item button, used when no slotted content is provided. |
147
+ | `value` _(required)_ | `string | number` | `undefined` | Sets the value emitted by the parent `p-segmented-control` when this item is selected. This property is*required**. |
148
+
149
+ #### Slots
150
+
151
+ | Slot | Required | Allowed tag names | Description |
152
+ | --- | --- | --- | --- |
153
+ | _(default)_ | no | — | Default slot for the content. |
154
+
155
+ ## Examples
156
+
157
+ | Example | When to use | File |
158
+ | --- | --- | --- |
159
+ | Default | Minimal default configuration. | [./examples/Default.tsx](./examples/Default.tsx) |
160
+ | Form | The `p-segmented-control` can be integrated into a form in two ways: **controlled** or **uncontrolled**, depending on your needs. | [./examples/Form.tsx](./examples/Form.tsx) |
161
+ | With Labels | Additional meta information can be displayed by setting a `label` on each child. | [./examples/WithLabels.tsx](./examples/WithLabels.tsx) |
162
+ | Slots | Use named slots when `label`, `description` or `message` need markup such as a link. | [./examples/Slots.tsx](./examples/Slots.tsx) |
@@ -0,0 +1,136 @@
1
+ import React from 'react';
2
+ import {
3
+ type InputSearchInputEventDetail,
4
+ PIcon,
5
+ PInputSearch,
6
+ PSelect,
7
+ PSelectOption,
8
+ type PSelectProps,
9
+ type SelectChangeEventDetail,
10
+ type SelectToggleEventDetail,
11
+ } from '@porsche-design-system/components-react';
12
+ import { useCallback, useRef, useState } from 'react';
13
+
14
+ const useDebounce = <T,>(callback: (value: T) => void, delay = 400) => {
15
+ const timer = useRef<number | undefined>(undefined);
16
+ return (value: T) => {
17
+ if (timer.current) clearTimeout(timer.current);
18
+ timer.current = window.setTimeout(() => callback(value), delay);
19
+ };
20
+ };
21
+
22
+ export const Example = () => {
23
+ const [value, setValue] = useState<PSelectProps['value']>(undefined);
24
+ const [options, setOptions] = useState<{ value: string; label: string }[]>([]);
25
+
26
+ const [searchValue, setSearchValue] = useState('');
27
+ const [initialLoading, setInitialLoading] = useState(false);
28
+ const [loading, setLoading] = useState(false);
29
+ const [error, setError] = useState<string | null>(null);
30
+
31
+ const hasLoadedOnce = useRef(false);
32
+ const currentFetchId = useRef(0);
33
+
34
+ // 💡Consider using a data-fetching library like React Query or SWR here.
35
+ // They provide built-in caching, deduplication, retries, and loading/error state management,
36
+ // which would make this async logic cleaner and more reliable than manual fetch handling.
37
+ const fetchOptions = useCallback(async (term?: string, isInitial?: boolean) => {
38
+ const fetchId = ++currentFetchId.current;
39
+ isInitial ? setInitialLoading(true) : setLoading(true);
40
+ try {
41
+ const url = term
42
+ ? `https://jsonplaceholder.typicode.com/users?username_like=${term}`
43
+ : `https://jsonplaceholder.typicode.com/users`;
44
+
45
+ const res = await fetch(url);
46
+ const data: { id: number; name: string; username: string }[] = await res.json();
47
+
48
+ // Ignore stale results
49
+ if (fetchId !== currentFetchId.current) return;
50
+
51
+ const newOptions = data.map((user) => ({
52
+ value: user.id.toString(),
53
+ label: `${user.name} (${user.username})`,
54
+ }));
55
+
56
+ setOptions(newOptions);
57
+ setError(null);
58
+ hasLoadedOnce.current = true;
59
+ } catch (err) {
60
+ console.error('Failed to fetch options', err);
61
+ setOptions([]);
62
+ setError('Failed to load options');
63
+ } finally {
64
+ isInitial ? setInitialLoading(false) : setLoading(false);
65
+ }
66
+ }, []);
67
+
68
+ const debouncedFetch = useDebounce(fetchOptions, 400);
69
+
70
+ const onInput = (e: CustomEvent<InputSearchInputEventDetail>) => {
71
+ const term = (e.target as HTMLElement & { value: string }).value;
72
+ setSearchValue(term);
73
+ debouncedFetch(term.trim() || undefined);
74
+ };
75
+
76
+ const onChange = (e: CustomEvent<SelectChangeEventDetail>) => {
77
+ setValue((e.target as HTMLElement & { value: string }).value);
78
+ };
79
+
80
+ const onToggle = async (e: CustomEvent<SelectToggleEventDetail>) => {
81
+ if (e.detail.open && !hasLoadedOnce.current) {
82
+ fetchOptions(undefined, true);
83
+ }
84
+ };
85
+
86
+ return (
87
+ <PSelect name="async-search-select" label="Async Search" value={value} onChange={onChange} onToggle={onToggle}>
88
+ <PInputSearch
89
+ slot="filter"
90
+ name="search"
91
+ value={searchValue}
92
+ loading={loading}
93
+ clear
94
+ indicator
95
+ compact
96
+ autoComplete="off"
97
+ onInput={onInput}
98
+ // Prevent bubbling
99
+ onBlur={(e: any) => e.stopPropagation()}
100
+ onChange={(e: any) => e.stopPropagation()}
101
+ />
102
+
103
+ {/* Initial skeleton loading */}
104
+ {initialLoading &&
105
+ !error &&
106
+ Array.from({ length: 9 }).map((_, i) => <div key={i} slot="options-status" className="skeleton h-[40px]" />)}
107
+
108
+ {/* Options */}
109
+ {options.map((opt) => (
110
+ <PSelectOption key={opt.value} value={opt.value}>
111
+ {opt.label}
112
+ </PSelectOption>
113
+ ))}
114
+
115
+ {/* No filter results */}
116
+ {!initialLoading && options.length === 0 && !error && (
117
+ <div
118
+ slot="options-status"
119
+ className="text-contrast-medium cursor-not-allowed py-static-sm px-[12px]"
120
+ role="alert"
121
+ >
122
+ <span aria-hidden="true">–</span>
123
+ <span className="sr-only">No results found</span>
124
+ </div>
125
+ )}
126
+
127
+ {/* Error state */}
128
+ {error && (
129
+ <div slot="options-status" className="flex gap-static-sm py-static-sm px-[12px]" role="alert">
130
+ <PIcon name="information" color="error" />
131
+ <span className="text-error">{error}</span>
132
+ </div>
133
+ )}
134
+ </PSelect>
135
+ );
136
+ };
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { PSelect, PSelectOption } from '@porsche-design-system/components-react';
3
+
4
+ export const Example = () => {
5
+ return (
6
+ <>
7
+ <PSelect name="options" label="Some Label" description="Some description">
8
+ <PSelectOption value="a">
9
+ Option A
10
+ </PSelectOption>
11
+ <PSelectOption value="b">
12
+ Option B
13
+ </PSelectOption>
14
+ <PSelectOption value="c">
15
+ Option C
16
+ </PSelectOption>
17
+ <PSelectOption value="d">
18
+ Option D
19
+ </PSelectOption>
20
+ <PSelectOption value="e">
21
+ Option E
22
+ </PSelectOption>
23
+ <PSelectOption value="f">
24
+ Option F
25
+ </PSelectOption>
26
+ </PSelect>
27
+ </>
28
+ )
29
+ }
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import {
3
+ PButton,
4
+ PSelect,
5
+ PSelectOption,
6
+ type PSelectProps,
7
+ PText,
8
+ type SelectChangeEventDetail,
9
+ } from '@porsche-design-system/components-react';
10
+ import { FormEvent, useState } from 'react';
11
+
12
+ export const Example = () => {
13
+ const [form, setForm] = useState({ mySelect: undefined });
14
+ const [lastSubmittedData, setLastSubmittedData] = useState<any>();
15
+
16
+ const onChange = (e: CustomEvent<SelectChangeEventDetail>) => {
17
+ const { name, value } = e.target as HTMLElement & PSelectProps;
18
+ setForm((prev) => ({
19
+ ...prev,
20
+ [name]: value,
21
+ }));
22
+ };
23
+
24
+ const onSubmit = (e: FormEvent<HTMLFormElement>) => {
25
+ e.preventDefault();
26
+ setLastSubmittedData(JSON.stringify(form));
27
+ };
28
+
29
+ const onReset = (e: FormEvent<HTMLFormElement>) => {
30
+ e.preventDefault();
31
+ setForm({ mySelect: undefined });
32
+ };
33
+
34
+ return (
35
+ <>
36
+ <form onSubmit={onSubmit} onReset={onReset} className="flex flex-col gap-fluid-sm">
37
+ <PSelect name="mySelect" label="Some Label" value={form.mySelect} onChange={onChange}>
38
+ <PSelectOption value="a">Option A</PSelectOption>
39
+ <PSelectOption value="b">Option B</PSelectOption>
40
+ <PSelectOption value="c">Option C</PSelectOption>
41
+ <PSelectOption value="d">Option D</PSelectOption>
42
+ <PSelectOption value="e">Option E</PSelectOption>
43
+ <PSelectOption value="f">Option F</PSelectOption>
44
+ </PSelect>
45
+ <div className="flex gap-fluid-sm">
46
+ <PButton type="submit">Submit</PButton>
47
+ <PButton type="reset">Reset</PButton>
48
+ </div>
49
+ <PText>Last submitted data: {lastSubmittedData}</PText>
50
+ </form>
51
+ </>
52
+ );
53
+ };
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { POptgroup, PSelect, PSelectOption } from '@porsche-design-system/components-react';
3
+
4
+ export const Example = () => {
5
+ return (
6
+ <>
7
+ <PSelect name="options" label="Some Label" description="Some description">
8
+ <POptgroup label="Some optgroup label 1">
9
+ <PSelectOption value="a">
10
+ Option A
11
+ </PSelectOption>
12
+ <PSelectOption value="b">
13
+ Option B
14
+ </PSelectOption>
15
+ <PSelectOption value="c">
16
+ Option C
17
+ </PSelectOption>
18
+ <PSelectOption value="d">
19
+ Option D
20
+ </PSelectOption>
21
+ <PSelectOption value="e">
22
+ Option E
23
+ </PSelectOption>
24
+ <PSelectOption value="f">
25
+ Option F
26
+ </PSelectOption>
27
+ </POptgroup>
28
+ <POptgroup label="Some optgroup label 2">
29
+ <PSelectOption value="g">
30
+ Option G
31
+ </PSelectOption>
32
+ <PSelectOption value="h">
33
+ Option H
34
+ </PSelectOption>
35
+ <PSelectOption value="i">
36
+ Option I
37
+ </PSelectOption>
38
+ </POptgroup>
39
+ </PSelect>
40
+ </>
41
+ )
42
+ }
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { PButton, PCheckbox, PSelect, PSelectOption, PText } from '@porsche-design-system/components-react';
3
+ import { type SubmitEvent, useState } from 'react';
4
+
5
+ export const Example = () => {
6
+ const [lastSubmittedData, setLastSubmittedData] = useState('none');
7
+ const [isRequired, setIsRequired] = useState(true);
8
+ const [hasDeselection, setHasDeselection] = useState(false);
9
+
10
+ const onChangeRequired = () => {
11
+ setIsRequired((prev) => !prev);
12
+ };
13
+
14
+ const onChangeDeselection = () => {
15
+ setHasDeselection((prev) => !prev);
16
+ };
17
+
18
+ const onSubmit = (e: SubmitEvent<HTMLFormElement>) => {
19
+ e.preventDefault();
20
+ const formData = new FormData(e.currentTarget);
21
+ setLastSubmittedData(formData.get('options')?.toString() || 'none');
22
+ };
23
+
24
+ return (
25
+ <>
26
+ <div className="flex flex-col gap-static-sm">
27
+ <PCheckbox label="Required" name="required" checked={isRequired} onChange={onChangeRequired} />
28
+ <PCheckbox
29
+ label="Allow deselection"
30
+ name="deselection"
31
+ checked={hasDeselection}
32
+ onChange={onChangeDeselection}
33
+ />
34
+ </div>
35
+ <form onSubmit={onSubmit} className="flex flex-col gap-fluid-sm mt-fluid-sm">
36
+ <PSelect name="options" label="Some Label" required={isRequired}>
37
+ {hasDeselection && <PSelectOption></PSelectOption>}
38
+ <PSelectOption value="1">Option 1</PSelectOption>
39
+ <PSelectOption value="2">Option 2</PSelectOption>
40
+ <PSelectOption value="3">Option 3</PSelectOption>
41
+ </PSelect>
42
+ <PButton type="submit">Submit</PButton>
43
+ </form>
44
+
45
+ <PText>Last submitted data: {lastSubmittedData}</PText>
46
+ </>
47
+ );
48
+ };