@codecademy/gamut

68.6.068.6.1-alpha.edab62.0
agent-tools/guidelines/foundations/modes.md
+agent-tools/guidelines/foundations/modes.mdNew file
+45
Index: package/agent-tools/guidelines/foundations/modes.md
===================================================================
--- package/agent-tools/guidelines/foundations/modes.md
+++ package/agent-tools/guidelines/foundations/modes.md
@@ -0,0 +1,45 @@
+# Color Modes
+
+Gamut uses **semantic color aliases** so components adapt to light/dark mode without configuration. See [color.md](color.md) for the full alias reference.
+
+## `<ColorMode>`
+
+Wraps a subtree in an explicit color mode. Nest to create scoped mode regions.
+
+```tsx
+import { ColorMode } from '@codecademy/gamut-styles';
+
+<ColorMode mode="light">{children}</ColorMode>   // force light
+<ColorMode mode="dark">{children}</ColorMode>    // force dark
+<ColorMode mode="system">{children}</ColorMode>  // follows OS preference
+```
+
+**Props**: `mode="light" | "dark" | "system"`
+
+## `<Background>`
+
+Use `<Background>` — not a raw `bg` prop — whenever setting a colored background on a section that contains text or interactive elements. It automatically switches the color mode inside to maintain accessible contrast.
+
+```tsx
+import { Background } from '@codecademy/gamut-styles';
+
+<Background bg="hyper">{children}</Background>
+```
+
+Nesting is supported — each `<Background>` creates its own accessible color context.
+
+## Hooks
+
+| Hook | Returns | Use |
+|---|---|---|
+| `useCurrentMode()` | `"light" \| "dark"` | Read active mode in JS |
+| `useColorMode()` | `[modeKey, modeColors, allModes]` | Access all mode data |
+| `usePrefersDarkMode()` | `boolean` | Read OS dark preference only |
+
+Import from `@codecademy/gamut-styles`.
+
+## Common mistakes
+
+- Do not use raw color tokens (`navy-400`, `white`) for text/backgrounds that must be accessible across modes — use semantic aliases.
+- Do not use a raw `bg` prop on colored sections containing content — use `<Background>` so contrast is guaranteed.
+- Do not manually toggle modes from `usePrefersDarkMode()` — use `<ColorMode mode="system">` instead.