Skip to content

Instantly share code, notes, and snippets.

@Jon20111
Created January 19, 2021 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jon20111/84b17c484fcb6f50c768271124462dde to your computer and use it in GitHub Desktop.
Save Jon20111/84b17c484fcb6f50c768271124462dde to your computer and use it in GitHub Desktop.
Customize TextField text color, alignment, and size
import React from "react";
import TextField from "@material-ui/core/TextField";
import Paper from "@material-ui/core/Paper";
import { withStyles } from "@material-ui/core/styles";
const StyledTextField = withStyles((theme) => ({
root: {
margin: theme.spacing(2),
width: 300,
"& .MuiInput-underline": {
color: theme.palette.primary.main,
height: 60,
"& input": {
textAlign: "right"
}
},
"& .MuiFormLabel-root": {
color: theme.palette.secondary.main
}
}
}))(TextField);
export default function CustomTextFields() {
return (
<>
<Paper>
<StyledTextField label="Custom" defaultValue="Custom TextField" />
</Paper>
<br />
<a href="https://medium.com/the-clever-dev/customizing-material-ui-textfield-text-color-alignment-width-and-height-2161daded871">
Click here for more Material UI TextField customization!
</a>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment