light-dark()color-schemecolor-schemelight-dark()
(see color-scheme: only light on :root. Your application uses the Light theme and
is protected from being recolored by the browser (see html element or any container to define the theme context:.scheme-light-dark — Automatically toggles based on System/OS settings. This is the recommended way to support
dark mode..scheme-only-light — Forces the Light theme and prevents the browser from recoloring it..scheme-only-dark — Forces the Dark theme and prevents the browser from recoloring it..scheme-light — Uses the Light theme, but still allows the browser to recolor it. Prefer .scheme-only-light..scheme-dark — Uses the Dark theme.only opts out of this behavior. This is why the Global Styles use color-scheme: only light as
default. Safari doesn't support automatic dark mode, so it is not affected.color-scheme: only light).scheme-only-light.scheme-light-dark.scheme-only-dark, .scheme-dark.scheme-lightImportant
.scheme-only-light instead of .scheme-light or color-scheme: light. Without
only, the browser recolors the page or section. The same applies to custom styles, e.g. when overriding the
color-scheme of a component: use color-scheme: only light instead of color-scheme: light.<meta name="color-scheme"> tag has no effect, because the color-scheme set by the Global Styles on
:root takes precedence. Use the .scheme-* classes instead.<html class="scheme-light-dark">
<body>
<p-button>I follow the OS theme</p-button>
<div class="scheme-dark">
<p-heading>Dark Section</p-heading>
<p-button>I use the Dark theme</p-button>
</div>
</body>
</html>
color-scheme utility classes do more than just update PDS components—they act as a global "source of truth" for
your entire styling stack. When you apply a .scheme-* class, it automatically synchronizes the theme across all our
supported styling tools:text-primary) automatically resolve
to the correct light or dark values.color-scheme defined on
the parent container.color-scheme defined on the parent container..scheme-only-light or .scheme-only-dark on a page section that must remain light or dark independently of its
parent scheme. This is useful for fixed campaign sections or other page islands within a page that otherwise follows the
user's system preference..campaign-section {
--p-color-canvas: #0e0e12;
--p-color-primary: #fff;
}
<html class="scheme-light-dark">
<body>
<main>
<section class="campaign-section scheme-only-dark">Dark campaign content</section>
<section class="campaign-section scheme-only-light">Light campaign content</section>
</main>
</body>
</html>
.campaign-section {
background-color: var(--p-color-canvas);
color: var(--p-color-primary);
}
prefers-color-scheme, use
.scheme-light-dark..scheme-only-light or .scheme-only-dark on the html element of the web content, based on the
active app theme.