Commit 8e5f7fe 1 parent 82bdcd7 commit 8e5f7fe Copy full SHA for 8e5f7fe
File tree 1 file changed +5
-2
lines changed
packages/ui/src/components/Theme
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use client' ;
2
2
3
- import { updateThemeAppearanceClass } from '@radix-ui/themes' ;
3
+ import { updateThemeAppearanceClass , useThemeContext } from '@radix-ui/themes' ;
4
4
5
5
const THEME_KEY = 'fuel-ui-theme' ;
6
6
7
7
export function useTheme ( ) {
8
+ const { appearance : theme , onAppearanceChange } = useThemeContext ( ) ;
9
+
8
10
function toggleTheme ( ) {
9
11
const current = localStorage . getItem ( THEME_KEY ) ;
10
12
const next = current === 'light' ? 'dark' : 'light' ;
11
13
updateThemeAppearanceClass ( next ) ;
14
+ onAppearanceChange ( next ) ;
12
15
localStorage . setItem ( THEME_KEY , next ) ;
13
16
}
14
17
15
- return { theme : localStorage . getItem ( THEME_KEY ) || 'dark' , toggleTheme } ;
18
+ return { theme, toggleTheme } ;
16
19
}
You can’t perform that action at this time.
0 commit comments