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

ThemeContext.ts

16 lines408 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 *
11 * @returns A getter for the current theme, `'light'` or `'dark'`. Defaults to
12 * `'dark'`.
13 */
14export function useTheme() {
15 return useContext(ThemeContext)