New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to style TextFields input color? #9574
Comments
This comment has been minimized.
This comment has been minimized.
@quantuminformation I'm glad you found a solution. I would encourage people to do it this way: import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import TextField from "@material-ui/core/TextField";
const styles = {
root: {
background: "black"
},
input: {
color: "white"
}
};
function CustomizedInputs(props) {
const { classes } = props;
return (
<TextField
defaultValue="color"
className={classes.root}
InputProps={{
className: classes.input
}}
/>
);
}
CustomizedInputs.propTypes = {
classes: PropTypes.object.isRequired
};
export default withStyles(styles)(CustomizedInputs); https://codesandbox.io/s/1370v7y4zj Notice that you can also target the global class names ( |
Any updates, how to make it working with |
@pankajparkar I have updated my previous answer to work with the latest version: #9574 (comment). I hope that help, let me know! Alternatively, we have a customization demo in https://material-ui.com/demos/text-fields/#customized-inputs. |
@oliviertassinari thanks alot. I had to remove Problem codepen here |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I also need exactly the same! |
Thanks for the solution but how would you do it if color is actually a parameter you want to pass to the CustomizedInput and not a static value as is the case in your example ? In my case I get an error : The section of my code that is of interest. It is a React.Component btw.
|
This comment has been minimized.
This comment has been minimized.
no inputProps, this's InputProps, capitale "I" |
-MUI brings a lot of problems... mui/material-ui#9574
Sorry to resurrect a dead thread, but in case someone comes across this with the same question:
Other ways to do it are probably better, but if you have some specific need for inline styling you can pass props to the grandchild via the InputBase/inputBase props (note the capitalizations of 'I' and 'i'):
|
There is no guidance on how to change the text colour of these inputs https://material-ui.com/demos/text-fields/
Do we just use external css to do this?
I also tried this but it doesn't pass TypeScript checks:
(50,11): error TS2339: Property 'inputProps' does not exist on type 'IntrinsicAttributes & TextFieldProps & { children?: ReactNode; }'.
This might be purely a TypeScript types issue
The text was updated successfully, but these errors were encountered: