1
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?

【ReactでBootstrapを使えるようにする方法】

Posted at

ReactでBootstrapを使ったので、インストールの仕方を忘れないように、備忘録として残しておきます!

1必要なパッケージをインストール

npm install react-bootstrap bootstrap

2BootstrapのCSSを読み込む
src/index.js または App.js の先頭で以下を追加

import 'bootstrap/dist/css/bootstrap.min.css';

3React Bootstrapのコンポーネントを使う
たとえばボタンを使いたい場合

import Button from 'react-bootstrap/Button';

function App() {
  return (
    <div>
      <Button variant="primary">プライマリーボタン</Button>
    </div>
  );
}

Bootstrapのクラスを直接書くのではなく、React用にラップされたコンポーネントを使えるのが特徴らしい!!

1
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
1
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?