Introduction
Reactstrap is a component library for Reactjs. It provides in-built Bootstrap components that provide flexibility and inbuilt validations, making it easy to create a UI. Reactstrap is similar to Bootstrap, but it has self-contained components.
You can check my previous articles in which we discussed how we add Reactstrap in Reactjs application from the below links.
In this article we will discuss the following Reactstrap components,
- Modals
- Toasts
- Tooltip
Prerequisites
- We should have a basic knowledge of HTML and JavaScript.
- Visual Studio Code be installed
- Node and NPM installed
Let's create a new React project by using the following command,
- npx create-react-app reactstrapcomponent
- npm install --save reactstrap react react-dom
- npm install --save bootstrap
- import 'bootstrap/dist/css/bootstrap.min.css';
Now, in Visual Studio code, go to src folder and create a new folder and inside this folder add 3 new components,
- Modals.js
- Toasts.js
- Tooltips.js
Modals is used to display a message or information in a popup window on click or focus event. Now open Modals.js file and add the following code in this component,
- import React, { useState } from 'react';
- import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
- import { Navbar, Nav, NavItem, NavLink } from 'reactstrap';
- const Models = (props) => {
- const {
- buttonLabel,
- className
- } = props;
- const [modal, setModal] = useState(false);
- const toggle = () => setModal(!modal);
- return (
- <div>
- <Navbar className="btn btn-warning" light expand="md">
- <Nav color="info" navbar>
- <NavItem className="hdr">
- <NavLink>Reactstrap Modals Components</NavLink>
- </NavItem>
- </Nav>
- </Navbar>
- <Button color="info" onClick={toggle}>Open Modal</Button>
- <Modal isOpen={modal} toggle={toggle} className={className}>
- <ModalHeader style={{ 'backgroundColor': "#0062cc" }} color="primary" toggle={toggle}>Modal title</ModalHeader>
- <ModalBody>
- Bengaluru (also called Bangalore) is the capital of India's southern Karnataka state. The center of India's high-tech industry, the city is also known for its parks and nightlife. By Cubbon Park, Vidhana Soudha is a Neo-Dravidian legislative building. Former royal residences include 19th-century Bangalore Palace, modeled after England’s Windsor Castle, and Tipu Sultan’s Summer Palace, an 18th-century teak structure.
- </ModalBody>
- <ModalFooter>
- <Button color="primary">Save</Button>
- <Button className="btn btn-danger">Cancel</Button>
- </ModalFooter>
- </Modal>
- </div>
- );
- }
- export default Models;
- import React from 'react';
- import logo from './logo.svg';
- import './App.css';
- import Models from './Models'
- function App() {
- return (
- <div className="App">
- <Models></Models>
- </div>
- );
- }
- export default App;
Now run the project and check the result.

Tooltips
Tooltip is a pop-up that displays a message or information on hover, click or focus event. Let's open Tooltips.js file and add the following code in this component.
- import React, { useState } from 'react';
- import { Tooltip, Button } from 'reactstrap';
- import { Navbar, Nav, NavItem, NavLink } from 'reactstrap';
- const Tooltipsdemo = (props) => {
- const [tooltipOpen, setTooltipOpen] = useState(false);
- const toggle = () => setTooltipOpen(!tooltipOpen);
- return (
- <div>
- <Navbar className="btn btn-warning" light expand="md">
- <Nav color="info" navbar>
- <NavItem className="hdr">
- <NavLink>Reactstrap Tooltips Components</NavLink>
- </NavItem>
- </Nav>
- </Navbar>
- <Button color="primary"><span href="#" id="btntip">Button</span></Button>
- <Tooltip placement="top" isOpen={tooltipOpen} autohide={false} target="btntip" toggle={toggle}>
- Tooltip Demo
- </Tooltip>
- </div>
- );
- }
- export default Tooltipsdemo;



Join the conversation! Your thoughts help the community grow.