UNPKG

3.09 kBTypeScriptView Raw
1import {
2 ThemeOptions as SystemThemeOptions,
3 Theme as SystemTheme,
4 SxProps,
5 CSSObject,
6 SxConfig,
7} from '@mui/system';
8import { Mixins, MixinsOptions } from './createMixins';
9import { Palette, PaletteOptions } from './createPalette';
10import { Typography, TypographyOptions } from './createTypography';
11import { Shadows } from './shadows';
12import { Transitions, TransitionsOptions } from './createTransitions';
13import { ZIndex, ZIndexOptions } from './zIndex';
14import { Components } from './components';
15import { CssVarsTheme, CssVarsPalette, ColorSystemOptions } from './createThemeWithVars';
16
17/**
18 * To disable custom properties, use module augmentation
19 *
20 * @example
21 * declare module '@mui/material/styles' {
22 * interface CssThemeVariables {
23 * enabled: true;
24 * }
25 * }
26 */
27export interface CssThemeVariables {}
28
29type CssVarsOptions = CssThemeVariables extends {
30 enabled: true;
31}
32 ? ColorSystemOptions
33 : {};
34
35export interface ThemeOptions extends Omit<SystemThemeOptions, 'zIndex'>, CssVarsOptions {
36 mixins?: MixinsOptions;
37 components?: Components<Omit<Theme, 'components'>>;
38 palette?: PaletteOptions;
39 shadows?: Shadows;
40 transitions?: TransitionsOptions;
41 typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
42 zIndex?: ZIndexOptions;
43 unstable_strictMode?: boolean;
44 unstable_sxConfig?: SxConfig;
45}
46
47interface BaseTheme extends SystemTheme {
48 mixins: Mixins;
49 palette: Palette & (CssThemeVariables extends { enabled: true } ? CssVarsPalette : {});
50 shadows: Shadows;
51 transitions: Transitions;
52 typography: Typography;
53 zIndex: ZIndex;
54 unstable_strictMode?: boolean;
55}
56
57// shut off automatic exporting for the `BaseTheme` above
58export {};
59
60type CssVarsProperties = CssThemeVariables extends { enabled: true }
61 ? Pick<
62 CssVarsTheme,
63 | 'applyStyles'
64 | 'colorSchemes'
65 | 'colorSchemeSelector'
66 | 'rootSelector'
67 | 'cssVarPrefix'
68 | 'defaultColorScheme'
69 | 'getCssVar'
70 | 'getColorSchemeSelector'
71 | 'generateThemeVars'
72 | 'generateStyleSheets'
73 | 'generateSpacing'
74 | 'shouldSkipGeneratingVar'
75 | 'vars'
76 >
77 : {};
78
79/**
80 * Our [TypeScript guide on theme customization](https://mui.com/material-ui/guides/typescript/#customization-of-theme) explains in detail how you would add custom properties.
81 */
82export interface Theme extends BaseTheme, CssVarsProperties {
83 cssVariables?: false;
84 components?: Components<BaseTheme>;
85 unstable_sx: (props: SxProps<Theme>) => CSSObject;
86 unstable_sxConfig: SxConfig;
87}
88
89/**
90 * @deprecated
91 * Use `import { createTheme } from '@mui/material/styles'` instead.
92 */
93export function createMuiTheme(options?: ThemeOptions, ...args: object[]): Theme;
94
95/**
96 * Generate a theme base on the options received.
97 * @param options Takes an incomplete theme object and adds the missing parts.
98 * @param args Deep merge the arguments with the about to be returned theme.
99 * @returns A complete, ready-to-use theme object.
100 */
101export default function createThemeNoVars(options?: ThemeOptions, ...args: object[]): Theme;
102
\No newline at end of file