ENGLISH·COURSE API
    Preparing search index...
    • Client hook: the theme a theme control shows, and a way to switch to the other one.

      Returns { currentTheme: ThemeName; toggle: () => void } | null

      The shown theme and toggle, or null while the theme is unknown

      Shared by every theme control — the header switch and the avatar menu's phone item — so they resolve legacy values and swap themes the same way.

      toggle flips the shown theme at once and applies it after THEME_SWITCH_MS. The provider runs with disableTransitionOnChange, which suspends every CSS transition at the instant a theme applies; applying it in the same frame would freeze the switch's slide mid-way. Under prefers-reduced-motion: reduce there is no slide to wait for, so the theme applies immediately.

      Returns null on the server and during hydration, and while next-themes has not read storage: a control rendered then would mismatch the server HTML (see useIsHydrated).

      const choice = useThemeChoice();
      if (!choice) return <Placeholder />;
      return <button onClick={choice.toggle}>{choice.currentTheme}</button>;