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.

Material UI の styled() ユーティリティは CSS を直接書く実装もできる

Last updated at Posted at 2022-03-09

@mui/styles が MUI v5 で legacy になったという事で、@mui/system について少し調べた時の memo.

createTheme, ThemeProvider を利用している想定の場合、公式のサンプルコードの通りこんな形となる。

import * as React from 'react';
import { styled, createTheme, ThemeProvider } from '@mui/system';

const Logo = styled('img')(({ theme }) => ({
 height: '32px',
}));

backtick(`) を利用すると、CSS がそのまま記述できる。

const Logo = styled('img')(
 ({ theme }) => `
 height: 32px;
`,
);

どちらかで揃えたいですね。

参考

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?