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

Use an explicit border for a boundary that must remain visible. Its width can increase independently of any color changes made by the browser.

HTML
<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

ClassCSS declarations
contrast-more:border-2border-width: 2px;
contrast-more:font-boldfont-weight: 700;
contrast-less:border-neutral-400border-color: oklch(0.74 0 0);
forced-colors:outlineoutline-style: solid;
forced-colors:border-currentborder-color: currentColor;
View full generated CSS
Compiled 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;
  }
}