Skip to main content

Overview

The useTheme hook detects and returns the current ChatGPT theme (light or dark).

Import

import { useTheme } from 'sunpeak';

Signature

function useTheme(): 'light' | 'dark' | null

Returns

return
'light' | 'dark' | null
The current ChatGPT theme, or null if not available.

Usage

import { useTheme } from 'sunpeak';

function MyWidget() {
  const theme = useTheme();

  return (
    <div className={theme === 'dark' ? 'dark-mode' : 'light-mode'}>
      Current theme: {theme}
    </div>
  );
}