I have a basic implementation of dark mode with material UI and React, the question is how to make TextField helper text, label, border changing according to dark and light mode toggled. TextField is:
<TextField helperText='Sample text' label="Title" variant="outlined" />
Updated: It's necessary TextField to have dark colored helperText, label, border in light mode, and light coloured in dark mode. There is basic implementation of dark, light mode:
import { createTheme, ThemeProvider } from '@material-ui/core/styles'
import Paper from '@material-ui/core/Paper'
import Switch from '@material-ui/core/Switch'
function App() {
const [dark, setDark] = useState(false)
const theme = createTheme({
palette: {
type: dark ? 'dark' : 'light',
},
})
return (
<Router>
<ThemeProvider theme={theme}>
<Paper>
<Header></Header>
<Switch checked={dark} onChange={() => setDark(!dark)} />
<main className='py-3'>
<Container>
<Routes>
<Route exact path="/" element={<HomeScreen />}></Route>
...
</Routes>
</Container>
</main>
<Footer></Footer>
</Paper>
</ThemeProvider>
</Router>
);
}
export default App;
Some of the elements correspond to light, dark mode toggling, TextField not.