aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/theme/useThemeMode.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/theme/useThemeMode.ts')
-rw-r--r--src/theme/useThemeMode.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/theme/useThemeMode.ts b/src/theme/useThemeMode.ts
new file mode 100644
index 0000000..9769684
--- /dev/null
+++ b/src/theme/useThemeMode.ts
@@ -0,0 +1,12 @@
+import { useContext } from 'react'
+import { ThemeModeContext, type ThemeModeValue } from './themeModeContext'
+
+export function useThemeMode(): ThemeModeValue {
+ const context = useContext(ThemeModeContext)
+
+ if (context === null) {
+ throw new Error('useThemeMode must be used inside ThemeModeProvider')
+ }
+
+ return context
+}