1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【MUI】@mui/material/stylesでhoverを書く【styled-component】

Last updated at Posted at 2022-01-04

@mui/material/stylesでhoverを書く

若干はまったのでメモ。

@mui/material/stylesでhoverやtransitionsを書こうとしたときにコンパイルエラーで弾かれまくったので、ここに書き方を記していきます。

実装方法

import * as React from 'react';
import { styled } from '@mui/material/styles';
import SendIcon from '@mui/icons-material/Send';
import LoadingButton from '@mui/lab/LoadingButton';
import { styled } from '@mui/material/styles';

const CustomButton = styled(LoadingButton)({
  backgroundColor: 'red',
  "&:hover": {
    backgroundColor: 'blue',
  },
});

export function Button = () => {

  return (
    <div>
      <CustomButton
        size="large"
        variant="contained"
        color="primary"
        onClick={handleClick}
        loading={loading}
        loadingPosition="end"
        endIcon={<SendIcon />}
        className={classes.button}
      >
        {btnLabel}
      </CustomButton>
    </div>
  )
}

ホバー前
image.png

ホバーなう
image.png

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?