Categories
React Answers

How to style React Material UI text field with JavaScript?

Spread the love

Sometimes, we want to style React Material UI text field with JavaScript.

In this article, we’ll look at how to style React Material UI text field with JavaScript.

How to style React Material UI text field with JavaScript?

To style React Material UI text field with JavaScript, we can use the sx or inputProps prop.

For instance, we write

<TextField sx={{ marginTop: 10 }} inputProps={{ sx: { color: "#fff" } }} />;

to set the sx prop to an object with the styles for the text field.

We also set inputProps to an object with the sx property set to an object with the styles to style the text field.

Conclusion

To style React Material UI text field with JavaScript, we can use the sx or inputProps prop.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.