UNPKG

@frank-auth/react

Version:

Flexible and customizable React UI components for Frank Authentication

22 lines (18 loc) 517 B
import { createContext, useContext } from "react"; import type { Theme, ThemeMode } from "./theme"; export type ThemeContextType = { mode: ThemeMode; setMode: (mode: ThemeMode) => void; toggleMode: () => void; theme: Theme; }; export const ThemeContext = createContext<ThemeContextType | undefined>( undefined, ); export const useTheme = () => { const context = useContext(ThemeContext); if (context === undefined) { throw new Error("useTheme must be used within a ThemeProvider"); } return context; };