Passing props to material UI style

后端 未结 7 561
暗喜
暗喜 2020-12-13 08:41

given card code as in here : card

how can I update the card style or any material UI style as from

    const styles = theme => ({
    card: {
           


        
7条回答
  •  臣服心动
    2020-12-13 08:59

    Here the Typescript solution:

    import React from 'react';
    import { makeStyles } from '@material-ui/core/styles';
    import Button from '@material-ui/core/Button';
    import {Theme} from '@material-ui/core';
    
    export interface StyleProps {
        height: number;
    }
    
    const useStyles = makeStyles(theme => ({
      root: {
        background: 'green',
        height: ({height}) => height,
      },
    }));
    
    export default function Hook() {
    
      const props = {
        height: 48
      }
    
      const classes = useStyles(props);
      return ;
    }
    

    If you want to play with it, try it in this CodeSandbox

提交回复
热议问题