Browse documentation
Reference / Variants & accessibility
Contrast and forced colors
Adjust the treatment of borders and controls when the user requests higher contrast or activates a forced-color palette.
Working example
Print status · Approved
Use an explicit border for a boundary that must remain visible. Its width can increase independently of any color changes made by the browser.
<p class="rounded border border-neutral-400 px-3 py-2 contrast-more:border-2 contrast-more:border-black forced-colors:border-current">
Print status · Approved
</p>Class reference
| Class | CSS declarations |
|---|---|
contrast-more:border-2 | border-width: 2px; |
contrast-more:font-bold | font-weight: 700; |
contrast-less:border-neutral-400 | border-color: oklch(0.74 0 0); |
forced-colors:outline | outline-style: solid; |
forced-colors:border-current | border-color: currentColor; |
View full generated CSS
@media (prefers-contrast: more) {
.contrast-more\:border-2 {
border-width: 2px;
}
.contrast-more\:font-bold {
font-weight: 700;
}
}
@media (prefers-contrast: less) {
.contrast-less\:border-neutral-400 {
border-color: oklch(0.74 0 0);
}
}
@media (forced-colors: active) {
.forced-colors\:border-current {
border-color: currentColor;
}
.forced-colors\:outline {
outline-style: solid;
}
}