light-dark(),
which is provided in the color-scheme.css stylesheet.<html> element or any ancestor element:.scheme-light — enforces the light color scheme.scheme-dark — enforces the dark color scheme.scheme-light-dark — automatically switches based on the user's system preferencecolor-scheme property and light-dark() function directly to control
html { color-scheme: light; } — enforces the light color schemehtml { color-scheme: dark; } — enforces the dark color schemehtml { color-scheme: light dark; } — automatically switches based on the user's system preferencelight-dark() polyfill is already included:/* Replace {js|angular|react|vue} with your framework, e.g. components-react */
@import '@porsche-design-system/components-{js|angular|react|vue}';
light-dark() polyfill without any other styles, you can import it separately:/* Replace {js|angular|react|vue} with your framework, e.g. components-react */
@import '@porsche-design-system/components-{js|angular|react|vue}/color-scheme.css';
/* @porsche-design-system/components-{js|angular|react|vue}/color-scheme.css */
.scheme-normal {
color-scheme: normal;
}
.scheme-dark {
color-scheme: dark;
}
.scheme-light {
color-scheme: light;
}
.scheme-light-dark {
color-scheme: light dark;
}
.scheme-only-dark {
color-scheme: only dark;
}
.scheme-only-light {
color-scheme: only light;
}
@supports not (color: light-dark(white, black)) {
:root,
.scheme-light,
.scheme-only-light,
.scheme-normal,
.scheme-light-dark {
--p-color-focus: #1a44ea;
--p-color-canvas: #fff;
--p-color-surface: hsl(240 10% 95%);
--p-color-frosted: hsl(240 5% 70% / 0.148);
--p-color-frosted-soft: hsl(234 9.8% 60% / 0.06);
--p-color-frosted-strong: hsl(236 6.5% 42% / 0.236);
--p-color-backdrop: hsl(240 5.3% 14.9% / 0.5);
--p-color-contrast-lower: hsl(234 6% 32.9% / 0.324);
--p-color-contrast-low: hsl(240 5.3% 14.9% / 0.5);
--p-color-contrast-medium: hsl(240 6.1% 7% / 0.6);
--p-color-contrast-high: hsl(240 7.1% 11% / 0.7);
--p-color-contrast-higher: hsl(240 8.7% 9% / 0.8);
--p-color-primary: hsl(225 66.7% 1.2%);
--p-color-success: hsl(115 77.5% 27.8%);
--p-color-success-low: hsl(115 77.5% 27.8% / 0.18);
--p-color-success-medium: hsl(115 77.5% 27.8% / 0.6);
--p-color-success-frosted: hsl(115 77.5% 27.8% / 0.18);
--p-color-success-frosted-soft: hsl(115 77.5% 27.8% / 0.1);
--p-color-warning: hsl(28 97.7% 34.1%);
--p-color-warning-low: hsl(28 97.7% 34.1% / 0.18);
--p-color-warning-medium: hsl(28 97.7% 34.1% / 0.6);
--p-color-warning-frosted: hsl(28 97.7% 34.1% / 0.18);
--p-color-warning-frosted-soft: hsl(28 97.7% 34.1% / 0.1);
--p-color-error: hsl(357 78% 41%);
--p-color-error-low: hsl(357 78% 41% / 0.18);
--p-color-error-medium: hsl(357 78% 41% / 0.6);
--p-color-error-frosted: hsl(357 78% 41% / 0.18);
--p-color-error-frosted-soft: hsl(357 78% 41% / 0.1);
--p-color-info: hsl(228 83.2% 51%);
--p-color-info-low: hsl(228 83.2% 51% / 0.18);
--p-color-info-medium: hsl(228 83.2% 51% / 0.6);
--p-color-info-frosted: hsl(228 83.2% 51% / 0.18);
--p-color-info-frosted-soft: hsl(228 83.2% 51% / 0.1);
}
.scheme-dark,
.scheme-only-dark {
--p-color-focus: #1a44ea;
--p-color-canvas: hsl(225 66.7% 1.2%);
--p-color-surface: hsl(240 2% 10%);
--p-color-frosted: hsl(240 2% 43% / 0.228);
--p-color-frosted-soft: hsl(240 3.7% 26.5% / 0.154);
--p-color-frosted-strong: hsl(240 1.5% 61.8% / 0.302);
--p-color-backdrop: hsl(240 5.3% 14.9% / 0.5);
--p-color-contrast-lower: hsl(240 1.5% 61.8% / 0.302);
--p-color-contrast-low: hsl(240 12.5% 96.9% / 0.45);
--p-color-contrast-medium: hsl(240 12.5% 96.9% / 0.56);
--p-color-contrast-high: hsl(240 12.5% 96.9% / 0.67);
--p-color-contrast-higher: hsl(240 12.5% 96.9% / 0.78);
--p-color-primary: hsl(225 100% 99%);
--p-color-success: hsl(157 84.9% 41.6%);
--p-color-success-low: hsl(157 84.9% 41.6% / 0.18);
--p-color-success-medium: hsl(157 84.9% 41.6% / 0.6);
--p-color-success-frosted: hsl(157 84.9% 41.6% / 0.26);
--p-color-success-frosted-soft: hsl(157 84.9% 41.6% / 0.1);
--p-color-warning: hsl(28 90.2% 56.1%);
--p-color-warning-low: hsl(28 90.2% 56.1% / 0.18);
--p-color-warning-medium: hsl(28 90.2% 56.1% / 0.6);
--p-color-warning-frosted: hsl(28 90.2% 56.1% / 0.26);
--p-color-warning-frosted-soft: hsl(28 90.2% 56.1% / 0.1);
--p-color-error: hsl(0 96.9% 62%);
--p-color-error-low: hsl(0 96.9% 62% / 0.18);
--p-color-error-medium: hsl(0 96.9% 62% / 0.6);
--p-color-error-frosted: hsl(0 96.9% 62% / 0.26);
--p-color-error-frosted-soft: hsl(0 96.9% 62% / 0.1);
--p-color-info: hsl(210 100% 54.5%);
--p-color-info-low: hsl(210 100% 54.5% / 0.18);
--p-color-info-medium: hsl(210 100% 54.5% / 0.6);
--p-color-info-frosted: hsl(210 100% 54.5% / 0.26);
--p-color-info-frosted-soft: hsl(210 100% 54.5% / 0.1);
}
@media (prefers-color-scheme: dark) {
.scheme-light-dark {
--p-color-focus: #1a44ea;
--p-color-canvas: hsl(225 66.7% 1.2%);
--p-color-surface: hsl(240 2% 10%);
--p-color-frosted: hsl(240 2% 43% / 0.228);
--p-color-frosted-soft: hsl(240 3.7% 26.5% / 0.154);
--p-color-frosted-strong: hsl(240 1.5% 61.8% / 0.302);
--p-color-backdrop: hsl(240 5.3% 14.9% / 0.5);
--p-color-contrast-lower: hsl(240 1.5% 61.8% / 0.302);
--p-color-contrast-low: hsl(240 12.5% 96.9% / 0.45);
--p-color-contrast-medium: hsl(240 12.5% 96.9% / 0.56);
--p-color-contrast-high: hsl(240 12.5% 96.9% / 0.67);
--p-color-contrast-higher: hsl(240 12.5% 96.9% / 0.78);
--p-color-primary: hsl(225 100% 99%);
--p-color-success: hsl(157 84.9% 41.6%);
--p-color-success-low: hsl(157 84.9% 41.6% / 0.18);
--p-color-success-medium: hsl(157 84.9% 41.6% / 0.6);
--p-color-success-frosted: hsl(157 84.9% 41.6% / 0.26);
--p-color-success-frosted-soft: hsl(157 84.9% 41.6% / 0.1);
--p-color-warning: hsl(28 90.2% 56.1%);
--p-color-warning-low: hsl(28 90.2% 56.1% / 0.18);
--p-color-warning-medium: hsl(28 90.2% 56.1% / 0.6);
--p-color-warning-frosted: hsl(28 90.2% 56.1% / 0.26);
--p-color-warning-frosted-soft: hsl(28 90.2% 56.1% / 0.1);
--p-color-error: hsl(0 96.9% 62%);
--p-color-error-low: hsl(0 96.9% 62% / 0.18);
--p-color-error-medium: hsl(0 96.9% 62% / 0.6);
--p-color-error-frosted: hsl(0 96.9% 62% / 0.26);
--p-color-error-frosted-soft: hsl(0 96.9% 62% / 0.1);
--p-color-info: hsl(210 100% 54.5%);
--p-color-info-low: hsl(210 100% 54.5% / 0.18);
--p-color-info-medium: hsl(210 100% 54.5% / 0.6);
--p-color-info-frosted: hsl(210 100% 54.5% / 0.26);
--p-color-info-frosted-soft: hsl(210 100% 54.5% / 0.1);
}
}
}
lightningcsslight-dark() function that is currently broken. To avoid any issues, we recommend disabling the lightningcss
polyfill for now since we also include our own polyfill for the global styles.
// vite.config.ts
+ import { Features } from "lightningcss"
export default defineConfig({
+ css: {
+ transformer: "lightningcss",
+ lightningcss: {
+ exclude: Features.LightDark,
+ },
+ },
});
// next.config.ts
const nextConfig: NextConfig = {
+ experimental: {
+ useLightningcss: true,
+ lightningCssFeatures: {
+ exclude: ['light-dark'],
+ },
+ },
};
