ui icon indicating copy to clipboard operation
ui copied to clipboard

style: :art: improve contrast for destructive color in dark mode

Open flixlix opened this issue 1 year ago • 2 comments

Related to https://github.com/shadcn-ui/ui/pull/282, but it was closed and not fixed

Before

Not enough contrast with background

Screenshot 2024-05-19 at 14 41 38

After

Screenshot 2024-05-19 at 14 40 41

flixlix avatar May 19 '24 12:05 flixlix

@flixlix is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 19 '24 12:05 vercel[bot]

For my own projects, I've decided to go with the following tailwind colors for appropriate contrast on text-based destructive states (and error messages):

bg-white text-red-600 dark:bg-zinc-950 dark:text-red-500

WCAG 2.0 level AA requires a contrast ratio of at least 4.5:1 for normal text.

  • Light mode bg-white text-red-600: 4.82:1
  • Dark mode bg-zinc-950 text-red-500: 5.28:1

Any lighter on the red in light mode (or darker in dark mode) results in the following contrast ratios:

  • Light mode bg-white text-red-500: 3.76:1
  • Dark mode bg-zinc-950 text-red-600: 4.11:1

Dark mode is better than light mode, but both are still below the minimum required contrast ratio of 4.5:1.

brhx avatar Oct 05 '24 12:10 brhx