Untitled
unknown
plain_text
4 years ago
1.7 kB
7
Indexable
import React from "react"; import { TextField } from "@material-ui/core"; import { withStyles, createStyles } from "@material-ui/core/styles"; const commonStyles = (theme) => createStyles({ root: {}, warningStyles: { "& .MuiFormLabel-root.Mui-error": { color: "orange !important" }, "& .MuiInput-underline.Mui-error:after": { borderBottomColor: "orange !important" }, "& .MuiFormHelperText-root.Mui-error": { color: "orange !important" } } }); class DemoComponent extends React.Component { render() { const { classes } = this.props; const _text1HasWarning = false; const _text2HasWarning = true; const _text3HasWarning = false; return ( <> <TextField error={false} className={_text1HasWarning ? classes.warningStyles : null} value="Valid Value" variant="standard" label="Valid label" helperText="Valid helper text" /> <br /> <br /> <br /> <TextField error={true} className={_text2HasWarning ? classes.warningStyles : null} value="warning value" variant="standard" label="warning label" helperText="warning helper text" /> <br /> <br /> <br /> <TextField error={true} className={_text3HasWarning ? classes.warningStyles : null} value="error value" variant="standard" helperText="error helper text" label="error label" /> </> ); } } export default withStyles(commonStyles)(DemoComponent);
Editor is loading...