From 4a07c82da8c3fb4aed4553c4de9a85b2792848cd Mon Sep 17 00:00:00 2001 From: Victor Casas Date: Wed, 4 May 2022 07:36:38 -0400 Subject: [PATCH] Add support CSS variables --- .../material-ui/input-adornment.tsx | 84 +++++++++++++++++++ .../src/InputAdornment/InputAdornment.js | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 docs/pages/experiments/material-ui/input-adornment.tsx diff --git a/docs/pages/experiments/material-ui/input-adornment.tsx b/docs/pages/experiments/material-ui/input-adornment.tsx new file mode 100644 index 00000000000000..06cdbdd00f36d5 --- /dev/null +++ b/docs/pages/experiments/material-ui/input-adornment.tsx @@ -0,0 +1,84 @@ +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 { InputAdornment, TextField } from '@mui/material'; + +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', + }, + }} + > + + kg, + }} + /> + + + kg, + }} + variant="filled" + /> + + + + + ); +} diff --git a/packages/mui-material/src/InputAdornment/InputAdornment.js b/packages/mui-material/src/InputAdornment/InputAdornment.js index b99572dd262e22..05dea355013323 100644 --- a/packages/mui-material/src/InputAdornment/InputAdornment.js +++ b/packages/mui-material/src/InputAdornment/InputAdornment.js @@ -47,7 +47,7 @@ const InputAdornmentRoot = styled('div', { maxHeight: '2em', alignItems: 'center', whiteSpace: 'nowrap', - color: theme.palette.action.active, + color: (theme.vars || theme).palette.action.active, ...(ownerState.variant === 'filled' && { // Styles applied to the root element if `variant="filled"`. [`&.${inputAdornmentClasses.positionStart}&:not(.${inputAdornmentClasses.hiddenLabel})`]: {