Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

ThemeContext.ts

14 lines400 Bytes

1import { createContext, useContext } from 'solid-js'
2import type { Accessor } from 'solid-js'
3​
4export const ThemeContext = createContext<Accessor<'light' | 'dark'>>(
5 () => 'dark' as const,
6)
7​
8/**
9 * Returns the devtools theme from context.
10 * @returns A getter for the current theme, `'light'` or `'dark'`. Defaults to `'dark'`.
11 */
12export function useTheme() {
13 return useContext(ThemeContext)