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'

Returns

Returns 'light' or 'dark' based on the current ChatGPT theme.

Usage

import { useTheme } from 'sunpeak';

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

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