13 lines
357 B
TypeScript
Raw Normal View History

2025-05-30 22:37:13 +02:00
import { useContext } from "react"
2025-06-01 09:37:49 -05:00
import { ThemeContext, type ThemeContextType } from "@/lib/ThemeContext"
2025-05-30 22:37:13 +02:00
2025-06-01 09:37:49 -05:00
/** Hook to get and set the active theme. */
export function useTheme(): ThemeContextType {
const context = useContext(ThemeContext);
2025-05-30 22:37:13 +02:00
2025-06-01 09:37:49 -05:00
if (!context) {
throw new Error("useTheme must be used within a ThemeProvider");
}
2025-05-30 22:37:13 +02:00
2025-06-01 09:37:49 -05:00
return context;
2025-05-30 22:37:13 +02:00
}