Adapt Material UI components based on props with styled-components

Veröffentlicht am: 15. März 2020

Lesedauer: 1 Min.

Kategorien:
  1. import Modules

import styled from 'styled-components' import { Button } from '@material-ui/core'

  1. Create a custom Component
const MyButton = styled(({ props, ...other }) => <Button {...other} />)({
  background: props => props.bg,
  color: 'white',
  '&:hover': {
    backgroundColor: props => props.bgHover,
  },
})
<MyButton>click me</MyButton>

Articles in related Categories

  • Material UI
  • 04. März 2020