0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

styled-jsxを使ってスタイルを定義する

Posted at

styled-jsxとは、ReactやNext.jsプロジェクトでコンポーネントごとのスタイル定義を可能にするライブラリです。

styled-jsxをインストールする

npm install styled-jsx

styled-jsxを使ってスタイルを定義する

HelloWorld.jsx
function HelloWorld() {
  return (
    <div>
      <p>Hello World</p>
      
      {/* ここにスタイルを記述します */}
      <style jsx>{`
        p {
          color: blue;
          font-size: 20px;
        }
      `}</style>
    </div>
  );
}

export default HelloWorld;

以上です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?