import { … } from '@porsche-design-system/components-{js|angular|react|vue}/emotion';
colorSchemeStyles in your global styles to enable the color scheme utilities and add a polyfill for
browsers that don’t yet support light-dark(). See the import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { colorSchemeStyles } from '@porsche-design-system/components-{js|angular|react|vue}/emotion';
import { Global } from '@emotion/react';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<Global styles={colorSchemeStyles} />
...
</StrictMode>
);
light-dark()color-schemecolorSchemeStyles, which generates utility classes and includes a polyfill
for browsers that do not yet support light-dark() (see
.scheme-light — Forces light mode..scheme-dark — Forces dark mode..scheme-light-dark — Dynamically follows system/OS settings.main.tsx to initialize the theme utilities.import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import './index.css';
import { PorscheDesignSystemProvider } from '@porsche-design-system/components-react';
import { App } from './App.tsx';
+ import { colorSchemeStyles } from '@porsche-design-system/components-react/emotion';
+ import { Global } from '@emotion/react';
createRoot(document.getElementById('root')!).render(
<StrictMode>
+ <Global styles={colorSchemeStyles} />
<PorscheDesignSystemProvider>
<App />
</PorscheDesignSystemProvider>
</StrictMode>
);
import styled from '@emotion/styled';
import { colorFrosted, colorPrimary } from '@porsche-design-system/components-react/emotion';
const MyComponent = styled.div({
backgroundColor: colorFrosted,
color: colorPrimary,
});
import { MyComponent } from './MyComponent';
<!-- Defined theme will be applied to all child elements -->
export const App = () => {
return (
<div className="scheme-dark">
<MyComponent></MyComponent>
</div>
);
};
