Member-only story
Reactstrap — Tabs and Toasts
3 min readSep 24, 2020
Reactstrap is a version Bootstrap made for React.
It’s a set of React components that have Boostrap styles.
In this article, we’ll look at how to add tabs and toasts with Reactstrap.
Tabs
We can add tabs with the Nav
component with the tabs
prop.
The content of each tab can be added with the TabContent
and TabPane
components.
For instance, we can write:
import React from "react";
import "bootstrap/dist/css/bootstrap.min.css";
import {
TabContent,
TabPane,
Nav,
NavItem,
NavLink,
Card,
Button,
CardTitle,
CardText,
Row,
Col
} from "reactstrap";export default function App() {
const [activeTab, setActiveTab] = React.useState("1"); const toggle = tab => {
if (activeTab !== tab) setActiveTab(tab);
}; return (
<div>
<Nav tabs>
<NavItem>
<NavLink
className={activeTab === "1" ? "active" : ""}
onClick={() => {
toggle("1");
}}
>
Tab1
</NavLink>
</NavItem>
<NavItem>
<NavLink
className={activeTab === "2" ? "active" : ""}
onClick={() => {
toggle("2");
}}…