Porsche Design SystemSearchNavigate to GitHub repository of Porsche Design SystemOpen sidebar
Dsr Ponyfill Table of Contents Function name: getDSRPonyfill() In SSR projects like NextJS, the Porsche Design System components are getting rendered on the server using native web platform API called Declarative Shadow DOM (DSR). The browser support is already good but still limited. Therefore, we provide a partial in @porsche-design-system/components-react package based on @webcomponents/template-shadowroot which needs to be injected before the closing </body> of your index.html. Supported options OptionDescriptionTypeDefaultformatDefines the output format of the partial. By default, it returns a html string. For jsx it returns a jsx element. For sha256 it returns a SHA-256 hash of the innerHTML to use in a Content Security Policy (CSP).'html' | 'jsx' | 'sha256''html' When using jsx in the format option, it is necessary to have react/jsx-runtime as a dependency in the project included. Examples Project integration differs based on the project setup. The following showcases the most common ways.
<!-- index.html -->
<body>
  <!--PLACEHOLDER_DSR_PONYFILL-->
</body>

<!-- package.json (tested on macOS, the script may need to be adjusted depending on the operating system used) -->
<!-- make sure to adjust the path to the index.html file -->
"scripts": {
  "prestart": "yarn replace",
  "replace": "placeholder='<!--PLACEHOLDER_DSR_PONYFILL-->' && partial=$placeholder$(node -e 'console.log(require(\"@porsche-design-system/components-js/partials\").getDSRPonyfill())') && regex=$placeholder'.*' && sed -i '' -E -e \"s^$regex^$partial^\" index.html"
}
OutputThe result of this partial looks like this:
<script>
!function(){"use strict";const e=e=>
null===e.parentElement,t=e=>
e.nodeType===Node.ELEMENT_NODE;HTMLTemplateElement.prototype.hasOwnProperty("shadowRoot")||(n=>
{var l;const o=[];let i=n.firstElementChild;for(;i!==n&&null!==i;)if("TEMPLATE"===i.tagName)o.push(i),i=i.content;else if(null!==i.firstElementChild)i=i.firstElementChild;else if(t(i)&&null!==i.nextElementSibling)i=i.nextElementSibling;else{let t;for(;i!==n&&null!==i;)if(e(i)){t=o.pop();const e=t.parentElement,n=t.getAttribute("shadowrootmode");if(i=t,"open"===n||"closed"===n){const l=t.hasAttribute("shadowrootdelegatesfocus");try{e.attachShadow({mode:n,delegatesFocus:l}).append(t.content)}catch{}}else t=void 0}else{const e=i.nextElementSibling;if(null!=e){i=e,void 0!==t&&t.parentElement.removeChild(t);break}const n=null===(l=i.parentElement)||void 0===l?void 0:l.nextElementSibling;if(null!=n){i=n,void 0!==t&&t.parentElement.removeChild(t);break}i=i.parentElement,void 0!==t&&(t.parentElement.removeChild(t),t=void 0)}}})(document.body)}();
</script>
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%