Dark Mode MDN for shadcn/ui

Dark Mode MDN is a shadcn/ui theme built around a neutral gray primary color (#d9d9d9) with neutral gray accents (#4c4e57). The light mode uses a neutral background (#28292e). Dark mode keeps the neutral gray primary (#d9d9d9) on a neutral background (#28292e).

Color palette

TokenLightDark
Background
#28292edarkslategray
#28292edarkslategray
Foreground
#f5f5f5whitesmoke
#f5f5f5whitesmoke
Card
#242429darkslategray
#242429darkslategray
Card foreground
#ffffffwhite
#ffffffwhite
Popover
#212226black
#212226black
Popover foreground
#ffffffwhite
#ffffffwhite
Primary
#d9d9d9gainsboro
#d9d9d9gainsboro
Primary foreground
#404040darkslategray
#404040darkslategray
Secondary
#404040darkslategray
#404040darkslategray
Secondary foreground
#d9d9d9gainsboro
#d9d9d9gainsboro
Muted
#2f313cdarkslategray
#2f313cdarkslategray
Muted foreground
#acafbedarkgray
#acafbedarkgray
Accent
#4c4e57darkslategray
#4c4e57darkslategray
Accent foreground
#e9eaeclavender
#e9eaeclavender
Destructive
#fe4d2atomato
#fe4d2atomato
Destructive foreground
#ffffffwhite
#ffffffwhite
Border
#383838darkslategray
#383838darkslategray
Input
#404040darkslategray
#404040darkslategray
Ring
#d9d9d9gainsboro
#d9d9d9gainsboro

Contrast

WCAG 2 contrast ratios between each background and its foreground color.

Light mode
Text on background13.25:1AAA
Text on card15.40:1AAA
Primary button7.32:1AAA
Secondary button7.37:1AAA
Muted text5.90:1AA
Accent6.89:1AA
Destructive3.32:1AA Large
Dark mode
Text on background13.25:1AAA
Text on card15.40:1AAA
Primary button7.32:1AAA
Secondary button7.37:1AAA
Muted text5.90:1AA
Accent6.89:1AA
Destructive3.32:1AA Large

CSS variables

Paste this into your globals.css to use Dark Mode MDN in your shadcn/ui project.

:root {
  --radius: 0.5rem;
  --background: oklch(0.283 0.009 276.783);
  --foreground: oklch(0.97 0 180);
  --muted: oklch(0.317 0.019 276.337);
  --muted-foreground: oklch(0.757 0.021 276.856);
  --popover: oklch(0.253 0.008 276.809);
  --popover-foreground: oklch(1 0 180);
  --card: oklch(0.263 0.008 276.8);
  --card-foreground: oklch(1 0 180);
  --border: oklch(0.341 0 158.199);
  --input: oklch(0.371 0 168.69);
  --primary: oklch(0.885 0 180);
  --primary-foreground: oklch(0.371 0 168.69);
  --secondary: oklch(0.371 0 168.69);
  --secondary-foreground: oklch(0.885 0 180);
  --accent: oklch(0.425 0.016 276.715);
  --accent-foreground: oklch(0.936 0.003 277.212);
  --destructive: oklch(0.668 0.218 33.104);
  --destructive-foreground: oklch(1 0 180);
  --ring: oklch(0.885 0 180);
  --chart-1: oklch(0.885 0 180);
  --chart-2: oklch(0.371 0 168.69);
  --chart-3: oklch(0.425 0.016 276.715);
  --chart-4: oklch(0.399 0 180);
  --chart-5: oklch(0.883 0.003 17.205);
}

.dark {
  --radius: 0.5rem;
  --background: oklch(0.283 0.009 276.783);
  --foreground: oklch(0.97 0 180);
  --muted: oklch(0.317 0.019 276.337);
  --muted-foreground: oklch(0.757 0.021 276.856);
  --popover: oklch(0.253 0.008 276.809);
  --popover-foreground: oklch(1 0 180);
  --card: oklch(0.263 0.008 276.8);
  --card-foreground: oklch(1 0 180);
  --border: oklch(0.341 0 158.199);
  --input: oklch(0.371 0 168.69);
  --primary: oklch(0.885 0 180);
  --primary-foreground: oklch(0.371 0 168.69);
  --secondary: oklch(0.371 0 168.69);
  --secondary-foreground: oklch(0.885 0 180);
  --accent: oklch(0.425 0.016 276.715);
  --accent-foreground: oklch(0.936 0.003 277.212);
  --destructive: oklch(0.668 0.218 33.104);
  --destructive-foreground: oklch(1 0 180);
  --ring: oklch(0.885 0 180);
  --chart-1: oklch(0.885 0 180);
  --chart-2: oklch(0.371 0 168.69);
  --chart-3: oklch(0.425 0.016 276.715);
  --chart-4: oklch(0.399 0 180);
  --chart-5: oklch(0.883 0.003 17.205);
}