forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDarkTheme.tsx
59 lines (53 loc) · 1.19 KB
/
DarkTheme.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React from 'react';
import Typography from '@material-ui/core/Typography';
import {
createStyles,
makeStyles,
ThemeProvider,
useTheme,
createMuiTheme,
Theme,
} from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
padding: theme.spacing(3),
textAlign: 'center',
backgroundColor: theme.palette.background.default,
color: theme.palette.text.primary,
},
}),
);
function Demo() {
const classes = useStyles();
const theme = useTheme();
return (
<div className={classes.root}>
<Typography>{`${theme.palette.type} theme`}</Typography>
</div>
);
}
const lightTheme = createMuiTheme({
palette: {
// This is the default, so only included for comparison.
type: 'light',
},
});
const darkTheme = createMuiTheme({
palette: {
// Switching the dark mode on is a single property value change.
type: 'dark',
},
});
export default function DarkTheme() {
return (
<div style={{ width: '100%' }}>
<ThemeProvider theme={darkTheme}>
<Demo />
</ThemeProvider>
<ThemeProvider theme={lightTheme}>
<Demo />
</ThemeProvider>
</div>
);
}