fokemal / client /src /theme-context.ts
automindy's picture
Sync to upstream v0.13.7, keep HF Space adaptations
dcedb25
Raw History Blame Contribute Delete
489 Bytes
import { createContext, useContext } from 'react'
export type Theme = 'system' | 'light' | 'dark'
export interface ThemeContextValue {
theme: Theme
setTheme: (theme: Theme) => void
resolvedDark: boolean
}
export const ThemeContext = createContext<ThemeContextValue | null>(null)
export function useTheme(): ThemeContextValue {
const context = useContext(ThemeContext)
if (!context) {
throw new Error('useTheme must be used within a ThemeProvider')
}
return context
}