# ColorSchemeSwitch

Supply UI 1.1.0. Helpers.

Lets the person choose light or dark for themselves, on their own device. The theme's `mode` stays the default. With it, wrap the page in `<ColorSchemeProvider>` at the top of `<body>` in the root layout and add `suppressHydrationWarning` to `<html>`: the saved choice is then applied before the page is drawn

Lets the person using the tool choose light or dark for themselves. Their choice wins over the owner's look on their own device only. Put it once, in the account menu or the footer, with <ColorSchemeProvider> in the root layout.

## Options

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Its name for screen readers, when no visible label names it. |
| `className` | `string` |  | More classes on the outer element, for layout around it (margins, grid placement), not to restyle it. |
| `labels` | `{ system: string; light: string; dark: string; }` | `{ system: 'Auto', light: 'Light', dark: 'Dark' }` | The three choices, in words. |

## CSS parts

With the CSS in parts (`/ui/css/`), it needs: `components/button.css`, `components/segmented-control.css`, `components/calendar.css`, besides the ones every page loads.

## Helpers: notes

Hooks and functions the components are made of, passed on so a project uses the same ones: keyboard shortcuts, options loaded while typing, search matching, saved preferences, screen-reader announcements, smooth sizes, the theme.

**Do**
- Use `useShortcut` for app-wide keys, and show the key with `formatShortcut` so it reads right on each computer.
- Use `announce()` to tell a screen reader what changed when nothing visible takes focus ("3 results").

**Don't**
- Don't turn off the smooth sizes `Toaster` starts; boxes would jump when their content changes.
