Created
August 18, 2020 03:43
-
-
Save Jon20111/3d6bc73f89ac26d97476cb2f00a21740 to your computer and use it in GitHub Desktop.
Material-UI example styling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { makeStyles } from '@material-ui/styles'; | |
import { Theme } from '@material-ui/core'; | |
export const useStyles = makeStyles((theme: Theme) => ({ | |
parentForm: { | |
backgroundColor: '#C0C0C0' | |
}, | |
customInput: { | |
margin: 12, | |
'&$disabled': { | |
borderColor: 'orange' | |
} | |
}, | |
root: { | |
'&$disabled $notchedOutline': { | |
borderColor: 'orange' | |
} | |
}, | |
disabled: {}, | |
notchedOutline: {} | |
}) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { FC } from 'react'; | |
import { TextField } from '@material-ui/core'; | |
import { useStyles } from './custom-text-field.styles'; | |
import styled from 'styled-components'; | |
const StyledTextField = styled(TextField)` | |
.MuiOutlinedInput-root { | |
margin: 12px; | |
&.Mui-disabled fieldset { | |
border-color: orange; | |
} | |
&:hover fieldset { | |
border-color: green; | |
} | |
} | |
`; | |
export const CustomTextField: FC = () => { | |
const classes = useStyles(); | |
return <form className={classes.parentForm}> | |
<StyledTextField | |
// className={classes.customInput} | |
variant='outlined' | |
disabled | |
label='Text Field 1' | |
// InputProps={{ | |
// classes: { | |
// root: classes.root, | |
// disabled: classes.disabled, | |
// notchedOutline: classes.notchedOutline | |
// } | |
// }} | |
/> | |
</form> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment