Skip to content

Instantly share code, notes, and snippets.

@Jon20111
Created May 22, 2020 18:34
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/6b7d1bf64e3dbdcdb7d818ebc0bf1d04 to your computer and use it in GitHub Desktop.
Save Jon20111/6b7d1bf64e3dbdcdb7d818ebc0bf1d04 to your computer and use it in GitHub Desktop.
A demonstration of how to override the default Material UI component style using useStyles
import React, { FC, useMemo } from 'react';
import { TextField, withStyles } from '@material-ui/core';
import { useStyles } from './form.styles';
export const Form: FC = () => {
const classes = useStyles();
const StyledTextField = useMemo(
() => {
return withStyles({
root: {
margin: 8
}
})(TextField);
}, []
);
return <form>
<StyledTextField variant='outlined' label='Text Field 1' />
<StyledTextField variant='outlined' label='Text Field 2' />
</form>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment