Skip to content

Instantly share code, notes, and snippets.

@Jon20111
Created August 18, 2020 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jon20111/3d6bc73f89ac26d97476cb2f00a21740 to your computer and use it in GitHub Desktop.
Save Jon20111/3d6bc73f89ac26d97476cb2f00a21740 to your computer and use it in GitHub Desktop.
Material-UI example styling
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: {}
})
);
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