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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *