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

theme.tsx

36 lines804 Bytes

1import { createContext, useContext } from 'solid-js'
2import type { JSX } from 'solid-js'
3​
4export const defaultTheme = {
5 background: '#222222',
6 backgroundAlt: '#292929',
7 foreground: 'white',
8 gray: '#444',
9 grayAlt: '#444',
10 inputBackgroundColor: '#fff',
11 inputTextColor: '#000',
12 success: '#80cb00',
13 danger: '#ff0085',
14 active: '#0099ff',
15 warning: '#ffb200',
16} as const
17​
18export type Theme = typeof defaultTheme
19interface ProviderProps {
20 theme: Theme
21 children?: JSX.Element
23​
24const ThemeContext = createContext(defaultTheme)
25​
26export function ThemeProvider({ children, theme, ...rest }: ProviderProps) {
27 return (
28 <ThemeContext.Provider value={theme} {...rest}>
29 {children}
30 </ThemeContext.Provider>
31 )
33​
34export function useTheme() {
35 return useContext(ThemeContext)