Skip to content

Instantly share code, notes, and snippets.

@SandyGifford
Last active February 14, 2022 16: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 SandyGifford/399d05989f851d68433aa7036cf52981 to your computer and use it in GitHub Desktop.
Save SandyGifford/399d05989f851d68433aa7036cf52981 to your computer and use it in GitHub Desktop.
VSC Snippet for Typescript/Material UI components
{
"MUI Component": {
"prefix": "muicomp",
"description": "Material UI component template",
"body": [
"import { VFC } from \"react\";",
"import { makeStyles } from \"@material-ui/core\";",
"import { ClassNameMap } from \"@material-ui/core/styles/withStyles\";",
"import clsx from \"clsx\";",
"",
"",
"const useStyles = makeStyles(theme => ({",
" root: {},",
"}), {",
" classNamePrefix: \"$1\",",
"});",
"",
"export type $1JSSClassKey = keyof ReturnType<typeof useStyles>;",
"",
"export type $1Props = {",
" classes?: Partial<ClassNameMap<$1JSSClassKey>>;",
" className?: string;",
"};",
"",
"export const ${1:name}: VFC<$1Props> = ({",
" className,",
" classes: extClasses,",
"}) => {",
" const classes = useStyles({",
" classes: extClasses,",
" });",
"",
" return <div className={clsx(classes.root, className)} />;",
"};",
""
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment