Issue with TextField not transitioning to dark mode in MUI5.0

I've been struggling to turn a MUI <TextField /> to dark mode. Despite trying various solutions such as using ThemeProvider and CSSBaseline, I haven't been able to achieve the desired result!

I have attempted the code below and researched multiple questions and answers on this issue but debugging it has proven to be challenging

For a visual representation of the output received, refer to the screenshot provided

import React from 'react';
import { Box, CssBaseline, TextField, Typography } from '@mui/material';
import { ThemeProvider, createTheme } from '@mui/material/styles';

const darkTheme = createTheme({
  palette: {
    type: 'dark',
    primary: {
      main: '#8985f2',
    },
    secondary: {
      main: '#ff4843',
    },
  },
  typography: {
    fontFamily: 'Poppins',
  },
});

const SignupScreen = () => {
  return (
    <ThemeProvider theme={darkTheme}>
      <CssBaseline /> ...
          ...
          ...
          ...
          ...
          <TextField
            id="outlined-basic"
            label="Outlined"
            variant="outlined"
            fullWidth
            color="primary"
          />
        </Box>
      </Box>
    </ThemeProvider>
  );
};

export default SignupScreen;

Answer №1

Uncertain about the version of MUI you are using? For version ^5.4.3 , consider updating the 'type' attribute to 'mode'.

    const darkTheme = createTheme({
  palette: {
    mode: 'dark',
    primary: {
      main: '#8985f2',
    },
    secondary: {
      main: '#ff4843',
    },
  },
  typography: {
    fontFamily: 'Poppins',
  },
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

CSS causing unexpected behavior in image slider

I am facing an issue with incorporating a code for an image slideshow into my website. The current CSS is causing the slideshow to malfunction. Without the slideshow code in the CSS, the image appears correctly on the screen and changes its source every 2 ...

Automatically adapt the height of elements to ensure they are consistently aligned on a single page

I'm working on adjusting the height of elements on my page https://i.sstatic.net/tqRs9.png My goal is to dynamically change the height of A and B based on screen height so they always fit within a single screen without requiring scrolling. Currentl ...

Creating a minimalistic floating placeholder in HTML and CSS without the need to define a background color for the placeholder

Hey there, I'm currently working on implementing a floating placeholder for an input field. However, I'm facing an issue where I don't want to set the placeholder with a background color due to the varying input backgrounds and styles in my ...

Using a material-ui-next Checkbox within a Redux Form for rendering

I am encountering a challenge while attempting to display a simple material-ui-next checkbox within a redux-form. I am referencing the official example and trying to modify it to work with the newer version of material-ui-next, as the example uses an older ...

A syntax error was encountered while trying to execute jQuery due to

I am continuously encountering an error regarding an illegal character in Firebug $('#service_chk').click(function () { var $this = $(this); if ($this.is(':checked')) { $('#service').css('display&apos ...

When attempting to execute the bot code, I encountered an "UnhandledPromiseRejectionWarning" and a "DeprecationWarning." Does anyone have a solution for resolving this issue?

I am in the process of creating a Discord bot for a server. When I entered "node ." into the terminal to run the bot, I encountered the following error: (node:17632) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided. at We ...

scrollable header within the confines of the container

I have been trying to find a solution for my scrolling issue, but I just can't seem to get it right. I want the content within a div to scroll inside its container without affecting the header. Here's the updated JSFiddle link with the jQuery cod ...

Display the HTML results within a div using jQuery autocomplete

My goal is to create an autocomplete search box. I have successfully filtered the results when typing in the textbox and verified it in the console as well as the HTML tab window. However, I am facing an issue with displaying the results below the textbox ...

What are the steps to resolve a Fetch request issue with a Node.js server?

I am attempting to make a simple POST request using the fetch method. I am working on building a contact form using Vanilla Javascript, HTML, and CSS on the front end, while utilizing Node.js / Express on the backend. Take a look at my front end code: ...

Display all keys and values in a dynamically populated object on my screen - React

I have a dynamic object with nested objects, and I want to display every key and value. Even if there are objects within the main object, I need to show their keys and values as well. Here is an example of the object: info:{ address:{ city: {__o ...

Set the class of the list item to "active" class

My approach to styling involves using a UL and li class to contain form selection options. I plan on hiding the radio button and using its value upon form submission. I have managed to enable checking the radio box when the <li> is clicked, but for s ...

Incorporating additional text following the creation of an image composite using HTML5

I am facing an issue with positioning two images on a canvas using HTML5. Despite changing the x and y properties, the images remain stuck at the top left corner (0, 0). This is different from how I can position text easily on the canvas. <canvas width ...

Creating a Like button using react.js

How can I make only the selected button change, instead of all at the same time when clicked? I have implemented a function that includes a Boolean state and toggles it const [like, setLike] = useState(false); const handleLike=()=> { setLike(! ...

Generate a visual distortion effect using WebGL and three.js

I'm currently learning three.js and experimenting with image transformations. After seeing a cool effect demonstrated here, I'm interested in replicating it. Can anyone provide guidance on the steps to achieve similar image transformations? So ...

Adjust the size of the text and the textarea at the same time

I am trying to resize text simultaneously while resizing the textarea in my code. I am using jQuery for this functionality. However, I believe there is an issue with the click function being separated. Any advice on how to fix this would be greatly appreci ...

Tabulator - Enhancing Filter Results Using a Second Tabulator

I've implemented a Tabulator that displays search results, here is the code: var table = new Tabulator("#json-table", { layout:"fitDataFill", //initialFilter:[{field:"title", type:"!=", value:"ignoreList.title"}], ajaxURL:tabUrl, ajax ...

Modifying an object's attribute in React.js by toggling a checkbox

As I delve into learning React, I am constructing a straightforward todo list. Here's the object contained within my initialState: getInitialState:function(){ return { items: [ { text:"Buy Fish", ...

Experimenting with material-ui Button wording

Currently, I am working with a material UI button and need to create a test to verify if it has rendered correctly. I attempted the following: expect(wrapper.find('.btn-class').text()).toBe('Next') Unfortunately, this test failed with ...

Combine the initial element of one array with the initial element of another array in JavaScript

Is there a more efficient way to concatenate the first item of one array with the first item of another array in JavaScript, and automate console.log for each pair? Check out the code snippet below: $("button#search").on("click", function(){ var inputVa ...

Resetting Mui input field while updating state causes issues

Lately, I've taken an interest in material design and came across a library called MUI, which seems to be a React port of Material UI. Everything works fine except for one issue - when I set any state, the fields reset.https://i.sstatic.net/Up7v1.gif ...