diff --git a/docs/pages/experiments/material-ui/list-subheader.tsx b/docs/pages/experiments/material-ui/list-subheader.tsx new file mode 100644 index 00000000000000..6044a8803cafe1 --- /dev/null +++ b/docs/pages/experiments/material-ui/list-subheader.tsx @@ -0,0 +1,71 @@ +import * as React from 'react'; +import { + Experimental_CssVarsProvider as CssVarsProvider, + useColorScheme, +} from '@mui/material/styles'; +import CssBaseline from '@mui/material/CssBaseline'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import Container from '@mui/material/Container'; +import Moon from '@mui/icons-material/DarkMode'; +import Sun from '@mui/icons-material/LightMode'; +import List from '@mui/material/List'; +import ListSubheader from '@mui/material/ListSubheader'; +import ListItem from '@mui/material/ListItem'; +import ListItemText from '@mui/material/ListItemText'; + +const ColorSchemePicker = () => { + const { mode, setMode } = useColorScheme(); + const [mounted, setMounted] = React.useState(false); + React.useEffect(() => { + setMounted(true); + }, []); + if (!mounted) { + return null; + } + + return ( + + ); +}; + +export default function CssVarsTemplate() { + return ( + + + + + + + div': { + placeSelf: 'center', + }, + }} + > + Subheader}> + + + + + + + + ); +} diff --git a/packages/mui-material/src/ListSubheader/ListSubheader.js b/packages/mui-material/src/ListSubheader/ListSubheader.js index 0b30e8f3ac19df..6fcb2db0d9d095 100644 --- a/packages/mui-material/src/ListSubheader/ListSubheader.js +++ b/packages/mui-material/src/ListSubheader/ListSubheader.js @@ -41,12 +41,12 @@ const ListSubheaderRoot = styled('li', { boxSizing: 'border-box', lineHeight: '48px', listStyle: 'none', - color: theme.palette.text.secondary, + color: (theme.vars || theme).palette.text.secondary, fontFamily: theme.typography.fontFamily, fontWeight: theme.typography.fontWeightMedium, fontSize: theme.typography.pxToRem(14), ...(ownerState.color === 'primary' && { - color: theme.palette.primary.main, + color: (theme.vars || theme).palette.primary.main, }), ...(ownerState.color === 'inherit' && { color: 'inherit', @@ -62,7 +62,7 @@ const ListSubheaderRoot = styled('li', { position: 'sticky', top: 0, zIndex: 1, - backgroundColor: theme.palette.background.paper, + backgroundColor: (theme.vars || theme).palette.background.paper, }), }));