Top Related Projects
Bootstrap components built with React
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
⚡️ Simple, Modular & Accessible UI Components for your React Applications
A utility-first CSS framework for rapid UI development.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Quick Overview
Reactstrap is a popular library that provides Bootstrap 4 components built with React. It offers a set of reusable UI components that are fully compatible with React, allowing developers to create responsive and visually appealing web applications quickly and efficiently.
Pros
- Easy integration with React projects
- Extensive set of pre-built components
- Customizable and flexible
- Good documentation and community support
Cons
- Dependency on Bootstrap CSS
- Learning curve for developers new to Bootstrap
- Limited design flexibility compared to custom-built components
- Potential performance overhead for smaller projects
Code Examples
- Using a Button component:
import React from 'react';
import { Button } from 'reactstrap';
const MyComponent = () => (
<Button color="primary">Click me</Button>
);
- Creating a responsive Navbar:
import React from 'react';
import { Navbar, NavbarBrand, Nav, NavItem, NavLink } from 'reactstrap';
const MyNavbar = () => (
<Navbar color="light" light expand="md">
<NavbarBrand href="/">My App</NavbarBrand>
<Nav className="ml-auto" navbar>
<NavItem>
<NavLink href="/home">Home</NavLink>
</NavItem>
<NavItem>
<NavLink href="/about">About</NavLink>
</NavItem>
</Nav>
</Navbar>
);
- Implementing a Modal:
import React, { useState } from 'react';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
const MyModal = () => {
const [modal, setModal] = useState(false);
const toggle = () => setModal(!modal);
return (
<div>
<Button color="danger" onClick={toggle}>Open Modal</Button>
<Modal isOpen={modal} toggle={toggle}>
<ModalHeader toggle={toggle}>Modal title</ModalHeader>
<ModalBody>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={toggle}>Do Something</Button>
<Button color="secondary" onClick={toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</div>
);
};
Getting Started
To start using Reactstrap in your React project:
- Install the package:
npm install reactstrap react react-dom
- Import Bootstrap CSS in your app's entry file (e.g.,
index.js
):
import 'bootstrap/dist/css/bootstrap.min.css';
- Import and use Reactstrap components in your React components:
import React from 'react';
import { Button } from 'reactstrap';
const App = () => (
<div>
<h1>Hello, Reactstrap!</h1>
<Button color="success">Get Started</Button>
</div>
);
export default App;
Now you can start building your React application using Reactstrap components!
Competitor Comparisons
Bootstrap components built with React
Pros of react-bootstrap
- Larger community and more frequent updates
- Closer alignment with official Bootstrap styles and components
- Better TypeScript support and type definitions
Cons of react-bootstrap
- Steeper learning curve for developers new to Bootstrap
- Larger bundle size due to comprehensive component set
- Less flexibility in customizing individual components
Code Comparison
react-bootstrap:
import { Button } from 'react-bootstrap';
<Button variant="primary">Click me</Button>
reactstrap:
import { Button } from 'reactstrap';
<Button color="primary">Click me</Button>
Both libraries provide similar component APIs, but react-bootstrap uses variant
for button styles, while reactstrap uses color
. react-bootstrap generally follows Bootstrap's class naming conventions more closely.
react-bootstrap tends to offer more comprehensive prop options for advanced customization, while reactstrap aims for simplicity and ease of use. The choice between the two often depends on project requirements, team familiarity with Bootstrap, and desired level of customization.
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
Pros of Material-UI
- More comprehensive component library with advanced components
- Highly customizable theming system
- Better TypeScript support and documentation
Cons of Material-UI
- Steeper learning curve due to complexity
- Larger bundle size, potentially impacting performance
- Opinionated design system may require more effort to override
Code Comparison
Material-UI:
import { Button, ThemeProvider, createTheme } from '@mui/material';
const theme = createTheme();
function App() {
return (
<ThemeProvider theme={theme}>
<Button variant="contained">Click me</Button>
</ThemeProvider>
);
}
Reactstrap:
import { Button } from 'reactstrap';
function App() {
return (
<Button color="primary">Click me</Button>
);
}
Material-UI offers more customization options and a theming system, while Reactstrap provides a simpler API closer to native Bootstrap. Material-UI's approach requires more setup but offers greater flexibility, whereas Reactstrap is more straightforward to use out of the box.
Both libraries provide React components for building user interfaces, but Material-UI offers a more comprehensive set of components and features at the cost of increased complexity. Reactstrap, being closer to Bootstrap, may be more familiar to developers with Bootstrap experience.
An enterprise-class UI design language and React UI library
Pros of Ant Design
- More comprehensive component library with a wider range of UI elements
- Stronger ecosystem with additional tools and resources
- Better internationalization support out of the box
Cons of Ant Design
- Steeper learning curve due to its complexity and extensive API
- Larger bundle size, which may impact initial load times
- More opinionated design system, potentially limiting customization flexibility
Code Comparison
Ant Design button example:
import { Button } from 'antd';
const MyComponent = () => (
<Button type="primary">Click me</Button>
);
Reactstrap button example:
import { Button } from 'reactstrap';
const MyComponent = () => (
<Button color="primary">Click me</Button>
);
Both libraries offer similar basic functionality, but Ant Design provides more built-in variants and properties for advanced customization. Reactstrap follows Bootstrap conventions more closely, making it familiar for developers with Bootstrap experience.
Ant Design is a more feature-rich UI library with a comprehensive set of components, while Reactstrap offers a lightweight alternative that closely aligns with Bootstrap's design principles. The choice between the two depends on project requirements, team familiarity, and desired level of customization.
⚡️ Simple, Modular & Accessible UI Components for your React Applications
Pros of Chakra UI
- More customizable and flexible design system
- Built-in dark mode support and color mode switching
- Better accessibility features out of the box
Cons of Chakra UI
- Steeper learning curve due to its extensive API
- Larger bundle size compared to Reactstrap
Code Comparison
Chakra UI:
import { Button, Box } from "@chakra-ui/react"
function Example() {
return (
<Box>
<Button colorScheme="blue">Click me</Button>
</Box>
)
}
Reactstrap:
import { Button } from "reactstrap"
function Example() {
return (
<div>
<Button color="primary">Click me</Button>
</div>
)
}
Both Chakra UI and Reactstrap are popular component libraries for React applications. Chakra UI offers a more modern and flexible approach to building user interfaces, with a focus on customization and accessibility. It provides a comprehensive set of components and utilities that can be easily styled and adapted to fit various design requirements.
Reactstrap, on the other hand, is based on Bootstrap and offers a simpler, more familiar API for developers who are already comfortable with Bootstrap. It has a smaller learning curve and may be easier to integrate into existing projects that use Bootstrap.
While Chakra UI provides more advanced features and customization options, it may require more time to learn and implement effectively. Reactstrap, being more straightforward, can be quicker to set up and use for simpler projects.
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Highly customizable with a utility-first approach
- Smaller bundle size due to purging unused styles
- Faster development with pre-built utility classes
Cons of Tailwind CSS
- Steeper learning curve for developers used to traditional CSS
- Can lead to longer class names and potentially cluttered HTML
- Requires additional configuration for optimal performance
Code Comparison
Reactstrap (Bootstrap-based component):
<Button color="primary" size="lg">
Large Button
</Button>
Tailwind CSS (utility classes):
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg">
Large Button
</button>
Summary
Tailwind CSS offers more flexibility and customization options compared to Reactstrap, which provides pre-built components based on Bootstrap. Tailwind's utility-first approach allows for rapid development and smaller bundle sizes, but it may require more initial setup and learning. Reactstrap, on the other hand, offers a more traditional component-based structure that's easier to pick up for developers familiar with Bootstrap, but it may be less flexible for custom designs.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Pros of styled-components
- Allows for dynamic styling based on props and theme
- Scoped styles prevent global CSS conflicts
- Better integration with JavaScript for complex styling logic
Cons of styled-components
- Steeper learning curve for developers new to CSS-in-JS
- Potentially larger bundle size due to runtime styling
- Can be overkill for simpler projects with minimal styling needs
Code Comparison
styled-components:
const Button = styled.button`
background-color: ${props => props.primary ? 'blue' : 'white'};
color: ${props => props.primary ? 'white' : 'blue'};
padding: 10px 15px;
border: 2px solid blue;
`;
reactstrap:
import { Button } from 'reactstrap';
<Button color="primary" size="lg">
Click me
</Button>
styled-components offers more flexibility in styling with JavaScript, while reactstrap provides pre-styled components based on Bootstrap. styled-components is ideal for custom designs and complex styling logic, whereas reactstrap is better suited for rapid development using familiar Bootstrap components and classes.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
reactstrap
Stateless React Components for Bootstrap 5.
If you're using Bootstrap 4, you'll need to use Reactstrap v8
Getting Started
Follow the create-react-app instructions to get started and then follow the reactstrap version of adding bootstrap.
tl;dr
npx create-react-app my-app
cd my-app/
npm start
or, if npx (Node >= 6 and npm >= 5.2 ) not available
npm install -g create-react-app
create-react-app my-app
cd my-app/
npm start
Then open http://localhost:3000/ to see your app. The initial structure of your app is setup. Next, let's add reactstrap and bootstrap.
Adding Bootstrap
Install reactstrap and Bootstrap from NPM. Reactstrap does not include Bootstrap CSS so this needs to be installed as well:
npm i bootstrap
npm i reactstrap react react-dom
Import Bootstrap CSS in the src/index.js
file:
import 'bootstrap/dist/css/bootstrap.css';
Import required reactstrap components within src/App.js
file or your custom component files:
import { Button } from 'reactstrap';
Now you are ready to use the imported reactstrap components within your component hierarchy defined in the render
method. Here is an example App.js
redone
using reactstrap.
Dependencies
Required Peer Dependencies
These libraries are not bundled with Reactstrap and required at runtime:
About the Project
This library contains React Bootstrap components that favor composition and control. The library does not depend on jQuery or Bootstrap javascript. However, Poppers.js via react-popper is relied upon for advanced positioning of content like Tooltips, Popovers, and auto-flipping Dropdowns.
There are a few core concepts to understand in order to make the most out of this library.
-
Your content is expected to be composed via props.children rather than using named props to pass in Components.
// Content passed in via props const Example = (props) => { return ( <p>This is a tooltip <TooltipTrigger tooltip={TooltipContent}>example</TooltipTrigger>!</p> ); } // Content passed in as children (Preferred) const PreferredExample = (props) => { return ( <p> This is a <a href="#" id="TooltipExample">tooltip</a> example. <Tooltip target="TooltipExample"> <TooltipContent/> </Tooltip> </p> ); }
-
Attributes in this library are used to pass in state, conveniently apply modifier classes, enable advanced functionality (like tether), or automatically include non-content based elements.
Examples:
isOpen
- current state for items like dropdown, popover, tooltiptoggle
- callback for togglingisOpen
in the controlling componentcolor
- applies color classes, ex:<Button color="danger"/>
size
- for controlling size classes. ex:<Button size="sm"/>
tag
- customize component output by passing in an element name or Component- boolean based props (attributes) when possible for alternative style classes or
visually-hidden
content
Documentation
Documentation search is powered by Algolia's DocSearch.
CodeSandbox Examples
Here are some ready-to-go examples for CodeSandbox that you can experiment with.
https://github.com/reactstrap/code-sandbox-examples
Contributing
Development
Install dependencies:
yarn install
Run examples at http://localhost:8080/ with webpack dev server:
yarn start
Run tests & coverage report:
yarn cover
Watch tests:
yarn test
Releasing
Release branches/versioning/notes will be automatically created and maintained by the release-please github action. When you're ready to publish the release, just merge the release branch. The release will be created, the new package will be published, and the updated docs will be deployed to https://reactstrap.github.io/.
In the wild
Organizations and projects using reactstrap
- airframe-react - demo - Airframe provides all the components a developer needs to build data-intensive web apps using React.
- component-template
- video-react
- CoreUI-Free-Bootstrap-Admin-Template - demo
- Admin dashboard example app built with reactstrap - demo
- DevExtreme React Grid - It's a stateless data grid built on top of
reactstrap
with paging, sorting, filtering, grouping, selection, editing and virtual scrolling features. - DevExtreme React Chart - A chart built on top of
reactstrap
that visualizes data using a variety of series types, including bar, line, area, scatter, pie, and more. - reactstrap-scrollspy - demo
- formstrap - demo - Let your
reactstrap
input component integrate seamlessly usingFormik
- Jimu UI - demo - The UI library for ArcGIS Experience Builder mapping platform.
Submit a PR to add to this list!
Looking to build, document and publish reusable components built on top of reactstrap
? Consider forking https://github.com/reactstrap/component-template to kickstart your project!
Top Related Projects
Bootstrap components built with React
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
⚡️ Simple, Modular & Accessible UI Components for your React Applications
A utility-first CSS framework for rapid UI development.
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot