import { … } from '@porsche-design-system/components-{js|angular|react|vue}/vanilla-extract';
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 // app.css.ts
import { colorSchemeStyles } from '@porsche-design-system/components-{js|angular|react|vue}/vanilla-extract';
import { type GlobalStyleRule, globalStyle } from '@vanilla-extract/css';
for (const { selector, rule } of colorSchemeStyles) {
globalStyle(selector, rule as GlobalStyleRule);
}
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.app.css.ts to initialize the theme utilities.// app.css.ts
+ import { colorSchemeStyles } from '@porsche-design-system/components-react/vanilla-extract';
+ import { type GlobalStyleRule, globalStyle } from '@vanilla-extract/css';
+ for (const { selector, rule } of colorSchemeStyles) {
+ globalStyle(selector, rule as GlobalStyleRule);
+ }
import { colorFrosted, colorPrimary } from '@porsche-design-system/components-react/vanilla-extract';
import { style } from '@vanilla-extract/css';
export const myComponent = style({
backgroundColor: colorFrosted,
color: colorPrimary,
});
import { myComponent } from './myComponent.css';
<!-- Defined theme will be applied to all child elements -->
export const App = () => {
return (
<div className="scheme-dark">
<div className={myComponent}></div>
</div>
);
};
