npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-color-mode-toggle.json --yesColor mode toggle
ProThe app's light and dark mode switch, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- ColorModeMenuThe three-way choice
import { ColorModeMenu, ColorModeToggle, useColorMode } from '@/components/ui/goop/color-mode-toggle';
import { TopBar, TopBarAction, TopBarGroup, TopBarRow, TopBarTitle } from '@/components/ui/goop/top-bar';
function NotesBar() {
const { mode } = useColorMode();
return (
<TopBar>
<TopBarRow>
<TopBarGroup>
<TopBarTitle>Field notes ({mode})</TopBarTitle>
</TopBarGroup>
<TopBarGroup align="end">
<TopBarAction icon="search" aria-label="Search notes" />
<ColorModeToggle />
<ColorModeMenu />
</TopBarGroup>
</TopBarRow>
</TopBar>
);
}Press the moon or the sun, the labelled toggle, or pick System, Light or Dark in the menu: the sample app beside them switches, and all three controls stay in step; the sample’s line says while the menu is open. The controls hold the sample’s mode, not the page’s, and keep nothing in storage; a light sample cannot be drawn inside a dark page.
When to use
- The app's light and dark mode switch.
- Also called: dark mode toggle or theme switcher.
Installation
Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Color mode toggle on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-color-mode-toggle.json --yesAdd the Goop Color mode toggle to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { ColorModeMenu, ColorModeToggle, useColorMode } from '@/components/ui/goop/color-mode-toggle';
import { TopBar, TopBarAction, TopBarGroup, TopBarRow, TopBarTitle } from '@/components/ui/goop/top-bar';
function NotesBar() {
const { mode } = useColorMode();
return (
<TopBar>
<TopBarRow>
<TopBarGroup>
<TopBarTitle>Field notes ({mode})</TopBarTitle>
</TopBarGroup>
<TopBarGroup align="end">
<TopBarAction icon="search" aria-label="Search notes" />
<ColorModeToggle />
<ColorModeMenu />
</TopBarGroup>
</TopBarRow>
</TopBar>
);
}- Fits: frame, settings (their recipes).
- Also known as: ThemeToggle, ModeToggle, DarkModeToggle, ThemeSwitcher.
- Every light/dark control is this one, ColorModeMenu or the account menu's AccountMenuColorMode, never a Switch or an IconButton wired to the class by hand (it would forget the system's setting). In a top bar it stands among the bar's actions (
TopBarActions), the same 28 px quiet button. - width, padding, gap, background, text: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| aria-label? | string | The icon toggle's name, the same in both modes (its pressed state says which): "Dark mode" when left out. |
| iconOnly? | boolean | The icon alone (the default); false writes words beside it: the mode a press shows ("Dark" while light, "Light" while dark), which name the button. |
| words? | ColorModeWords | The words, each replaceable. |
| value? | 'light' | 'dark' | The mode, held by the caller (with onValueChange); with this and defaultValue left out, the page's own. |
| defaultValue? | ColorMode | The page's starting mode while no choice is kept (the system's when left out); a kept choice beats it. |
| onValueChange? | (value: 'light' | 'dark') => void | Called with the mode a press asks for; the page's mode changes only when the toggle is left to the page. |
| type? | 'button' | 'submit' | 'reset' | |
| onClick? | (event: MouseEvent) => void | |
| disabled? | boolean |
- Takes every prop of IconButton but aria-pressed and children (its page: icon-button.md)
- State: value (value / defaultValue / onValueChange)
- Types: ColorModeWords = { system?: string; light?: string; dark?: string }
| Part | What it is |
|---|---|
| ColorModeMenu | The three-way choice; its props: color-mode-toggle--color-mode-menu.md |
- useColorMode
- data-slot values (to select a part by): color-mode-menu, color-mode-toggle
Keyboard
| Key | What it does |
|---|---|
| Enter | Switch to the other mode (the menu: open it) |
| Space | Switch to the other mode (the menu: open it) |
| ArrowDown ArrowUp | In the open menu: move between System, Light and Dark |
| Escape | Close the menu, the focus back on its button |
Accessibility
- The part itself answers the keys above.
- hover, active, focus-within: the browser's own (:hover, :active, :focus-within): write nothing
Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:
| State | Drawn by |
|---|---|
| pressed | the attribute aria-pressed |
| disabled | the prop disabled |
Notes for AI
Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.