'Change TextareaAutosize color in React with mui

I'm new at React and using mui components.

While I'm trying to set color to TextareaAutosize mui component with code like this:

import * as React from 'react';
import TextareaAutosize from '@mui/material/TextareaAutosize';
import { blue } from '@mui/material/colors';

export default function EmptyTextarea() {
  return (
    <TextareaAutosize
      aria-label="empty textarea"
      placeholder="Empty"
      style={{ width: 200, color: blue, background: blue}}
      //Also not works: color="{blue}"
    />
  );
}

the color of the component not changed.

Thanks a lot!



Solution 1:[1]

<TextareaAutosize /> renders a plain HTMLTextAreaElement.

Which means this CSS will work:

textarea {
  background-color: #222;
  color: #BADA55;
}

Working demo: https://codesandbox.io/s/maxheighttextarea-material-demo-forked-5hc8nv?file=/index.css

If you want to scope the CSS to your particular instance, give it an id and use it in the CSS selector.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1