Monday, October 6, 2025
HomeLanguagesReactJS Reactstrap Introduction

ReactJS Reactstrap Introduction

Reactstrap is a bootstrap-based React UI library that is used to make good-looking webpages with its seamless and easy-to-use component. Reactstrap does not embed its own style, but it depends upon the Bootstrap CSS framework for its styles and theme.

Prerequisites:

  • Good knowledge of react.
  • Good knowledge of Bootstrap.

Install Reactstrap: You can install it with npm or yarn by the following the command:

npm i reactstrap bootstrap --save
// or
yarn add reactstrap

Reactstrap currently requires, React 16.8 or higher. Reactstrap is currently compatible with Bootstrap 5.1. If you are using Bootstrap 4, you’ll need to use Reactstrap v8.

Import Bootstrap CSS in the src/index.js file:

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

Now you can simply import Reactstrap components in your application like

import { Button } from 'reactstrap';

By using CDN: Reactstrap can be included directly in your application’s bundle and linked directly to a CDN.

https://cdnjs.cloudflare.com/ajax/libs/reactstrap/4.8.0/reactstrap.min.js

Use: To use Reactstrap primarily, we have to create a React app by the following code:

npx create-react-app appname

Change directory to appname by:

cd appname

Now the app structure will look like this:

 

Example 1: In this example, we are creating a simple alert box using Reactstrap.

Javascript




import React from "react";
import { Alert } from 'reactstrap';
  
function App() {
    return (
        <div>
            <Alert color="info">
                Hello, I am an alert 
            </Alert>
        </div>
    )
}
  
export default App;


Output:

 

Example 2: In this example, we are creating a simple login for using Reactstrap.

Javascript




import React from "react";
import { Form, FormGroup, Label, Input, Button } from 'reactstrap';
  
function App() {
    return (
        <div>
            <Form>
                <FormGroup>
                    <Label for="exampleEmail">
                        Email
                    </Label>
                    <Input
                        id="exampleEmail"
                        name="email"
                        placeholder="Enter Your email"
                        type="email"
                    />
                </FormGroup>
                <FormGroup>
                    <Label for="examplePassword">
                        Password
                    </Label>
                    <Input
                        id="examplePassword"
                        name="password"
                        placeholder="Enter your unique password"
                        type="password"
                    />
                </FormGroup>
                <Button>
                    Submit
                </Button>
            </Form>
        </div>
    )
}
  
export default App;


Output:

 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32338 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6707 POSTS0 COMMENTS
Nicole Veronica
11871 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6825 POSTS0 COMMENTS
Ted Musemwa
7089 POSTS0 COMMENTS
Thapelo Manthata
6779 POSTS0 COMMENTS
Umr Jansen
6781 POSTS0 COMMENTS