theming

Use when an app uses @pierre/theming to list, resolve, select, switch, persist, or apply themes, including color modes, theme controllers, React state, UI colors, and bundled Pierre or Shiki collections.

Install
npx skills add 'https://github.com/pierrecomputer/pierre/tree/main/skills/theming'
Download bundle ↓
main · 1831817Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md

Recipe: use a theme controller in React

Create the controller in a module. Read it with useThemeController:

import { useEffect } from 'react';
import { useThemeController } from '@pierre/theming/react';

import { themeController } from './theme-controller';

export function ThemeControls() {
  const state = useThemeController(themeController);

  useEffect(() => {
    document.documentElement.dataset.colorScheme = state.resolvedColorScheme;
  }, [state.resolvedColorScheme]);

  return (
    <button
      type="button"
      onClick={() =>
        themeController.setColorMode(
          state.resolvedColorScheme === 'dark' ? 'light' : 'dark'
        )
      }
    >
      Use {state.resolvedColorScheme === 'dark' ? 'light' : 'dark'} mode
    </button>
  );
}

Pass state.resolvedTheme to code or tree surfaces. Use normalizeThemeColors when a React component needs workbench UI colors.

Referenced from SKILL.md