Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-color-mode-toggle.json --yes

Color mode toggle

Pro

The app's switch between light and dark, as a button or a menu, for React and Tailwind CSS. Part of Goop Pro.

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 switch between light and dark, as a button or a menu.
  • 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.

Terminal
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-color-mode-toggle.json --yes
PROMPT
Add the Goop Color mode toggle to this project. The install steps are at https://goop.so/docs/install.md

Usage

TSX
import { ColorModeToggle, ColorModeMenu, useColorMode } from '@/components/ui/goop/color-mode-toggle';

<>
  <ColorModeToggle />
  <ColorModeToggle iconOnly={false} />
  <ColorModeMenu />
</>
  • Fits: frame (its recipe).
  • Also known as: ThemeToggle, ModeToggle, DarkModeToggle, ThemeSwitcher.
  • Every light/dark control is this one or ColorModeMenu, 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; the README's head script opens the page in the kept mode with no flash.
  • width: add no class for these.

API reference

Options
OptionTypeWhat it does
aria-label?stringThe icon toggle's name, the same in both modes (its pressed state says which): "Dark mode" when left out.
iconOnly?booleanThe 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?ColorModeWordsThe 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?ColorModeThe page's starting mode while no choice is kept (the system's when left out); a kept choice beats it.
onValueChange?(value: 'light' | 'dark') => voidCalled 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 = { light?: string; dark?: string; system?: string }
Parts
PartWhat it is
ColorModeMenuThe 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

ColorModeMenu

The three-way choice.

TSX
import { ColorModeMenu } from '@/components/ui/goop/color-mode-toggle';

Options

  • aria-label?: string — The trigger's name: "Appearance" when left out.
  • words?: ColorModeWords — The rows' words, each replaceable.
  • value?: 'system' | 'light' | 'dark' — The choice, held by the caller (with onValueChange); with this and defaultValue left out, the page's own.
  • defaultValue?: ColorModeChoice — The page's starting choice while none is kept (system when left out); a kept choice beats it.
  • onValueChange?: (value: 'system' | 'light' | 'dark') => void — Called with the row picked; the page's mode changes only when the menu is left to the page.
  • open?: boolean — The menu open, held by the caller (with onOpenChange).
  • defaultOpen?: boolean — Open when it first draws.
  • onOpenChange?: (open: boolean) => void — Called as the menu opens and closes.
  • container?: HTMLElement | null — Where the menu is portalled; the end of <body> when left out.
  • Also takes: type?: 'button' | 'submit' | 'reset'; onClick?: (event: MouseEvent) => void; disabled?: boolean; tooltip?: string | false; tooltipKeys?: readonly string[]; loading?: boolean = false; loadingLabel?: string = 'Loading'
  • Types: ColorModeWords = { light?: string; dark?: string; system?: string }

Keyboard

KeyWhat it does
EnterSwitch to the other mode (the menu: open it)
SpaceSwitch to the other mode (the menu: open it)

Accessibility

  • The part itself answers the keys above.
  • hover, active, focus-visible: the browser's own (:hover, :active, :focus-visible): write nothing

Its states are drawn from attributes and props, so assistive technology and your agent read the same thing:

StateDrawn by
disabledthe 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.

goop.so/themes/trail/components/color-mode-toggle.md · the page as Markdown
Theme
Install with your agentnpx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-color-mode-toggle.json --yes

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.