1 | [![reactstrap](https://cloud.githubusercontent.com/assets/399776/13906899/1de62f0c-ee9f-11e5-95c0-c515fee8e918.png)](https://reactstrap.github.io)
|
2 |
|
3 | [![NPM Version](https://img.shields.io/npm/v/reactstrap.svg?branch=master)](https://www.npmjs.com/package/reactstrap) [![Build Status](https://github.com/reactstrap/reactstrap/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/reactstrap/reactstrap) [![Coverage Status](https://coveralls.io/repos/github/reactstrap/reactstrap/badge.svg?branch=master)](https://coveralls.io/github/reactstrap/reactstrap?branch=master) [![License](https://img.shields.io/npm/l/reactstrap.svg)](https://github.com/reactstrap/reactstrap/blob/master/LICENSE)
|
4 |
|
5 | # reactstrap
|
6 |
|
7 | Stateless React Components for Bootstrap 5.
|
8 |
|
9 | If you're using Bootstrap 4, you'll need to use [Reactstrap v8](https://deploy-preview-2356--reactstrap.netlify.app/)
|
10 |
|
11 | ## Getting Started
|
12 |
|
13 | Follow the [create-react-app instructions](https://create-react-app.dev/docs/getting-started) to get started and then follow the reactstrap version of [adding bootstrap](#adding-bootstrap).
|
14 |
|
15 | ### tl;dr
|
16 |
|
17 | ```
|
18 | npx create-react-app my-app
|
19 | cd my-app/
|
20 | npm start
|
21 | ```
|
22 | or, if npx (Node >= 6 and npm >= 5.2 ) not available
|
23 |
|
24 | ```
|
25 | npm install -g create-react-app
|
26 |
|
27 | create-react-app my-app
|
28 | cd my-app/
|
29 | npm start
|
30 | ```
|
31 |
|
32 | Then open [http://localhost:3000/](http://localhost:3000/) to see your app. The initial structure of your app is setup. Next, let's [add reactstrap and bootstrap](#adding-bootstrap).
|
33 |
|
34 | ### Adding Bootstrap
|
35 |
|
36 | Install reactstrap and Bootstrap from NPM. Reactstrap does not include Bootstrap CSS so this needs to be installed as well:
|
37 |
|
38 | ```
|
39 | npm i bootstrap
|
40 | npm i reactstrap react react-dom
|
41 | ```
|
42 |
|
43 | Import Bootstrap CSS in the ```src/index.js``` file:
|
44 |
|
45 | ```js
|
46 | import 'bootstrap/dist/css/bootstrap.css';
|
47 | ```
|
48 |
|
49 | Import required reactstrap components within ```src/App.js``` file or your custom component files:
|
50 |
|
51 | ```js
|
52 | import { Button } from 'reactstrap';
|
53 | ```
|
54 |
|
55 | Now you are ready to use the imported reactstrap components within your component hierarchy defined in the render
|
56 | method. Here is an example [`App.js`](https://gist.github.com/Thomas-Smyth/006fd507a7295f17a8473451938f9935) redone
|
57 | using reactstrap.
|
58 |
|
59 | ### Dependencies
|
60 |
|
61 | ##### Required Peer Dependencies
|
62 |
|
63 | These libraries are not bundled with Reactstrap and required at runtime:
|
64 |
|
65 | * [**react**](https://www.npmjs.com/package/react)
|
66 | * [**react-dom**](https://www.npmjs.com/package/react-dom)
|
67 |
|
68 | ## About the Project
|
69 |
|
70 | This library contains React Bootstrap components that favor composition and control. The library does not depend on jQuery or Bootstrap javascript. However, [Poppers.js](https://popper.js.org/) via [react-popper](https://github.com/popperjs/react-popper) is relied upon for advanced positioning of content like Tooltips, Popovers, and auto-flipping Dropdowns.
|
71 |
|
72 | There are a few core concepts to understand in order to make the most out of this library.
|
73 |
|
74 | 1. Your content is expected to be composed via props.children rather than using named props to pass in Components.
|
75 |
|
76 | ```js
|
77 | // Content passed in via props
|
78 | const Example = (props) => {
|
79 | return (
|
80 | <p>This is a tooltip <TooltipTrigger tooltip={TooltipContent}>example</TooltipTrigger>!</p>
|
81 | );
|
82 | }
|
83 |
|
84 | // Content passed in as children (Preferred)
|
85 | const PreferredExample = (props) => {
|
86 | return (
|
87 | <p>
|
88 | This is a <a href="#" id="TooltipExample">tooltip</a> example.
|
89 | <Tooltip target="TooltipExample">
|
90 | <TooltipContent/>
|
91 | </Tooltip>
|
92 | </p>
|
93 | );
|
94 | }
|
95 | ```
|
96 |
|
97 | 2. 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.
|
98 |
|
99 | Examples:
|
100 |
|
101 | - `isOpen` - current state for items like dropdown, popover, tooltip
|
102 | - `toggle` - callback for toggling `isOpen` in the controlling component
|
103 | - `color` - applies color classes, ex: `<Button color="danger"/>`
|
104 | - `size` - for controlling size classes. ex: `<Button size="sm"/>`
|
105 | - `tag` - customize component output by passing in an element name or Component
|
106 | - boolean based props (attributes) when possible for alternative style classes or `visually-hidden` content
|
107 |
|
108 |
|
109 | ## [Documentation](https://reactstrap.github.io)
|
110 |
|
111 | https://reactstrap.github.io
|
112 |
|
113 | Documentation search is powered by [Algolia's DocSearch](https://community.algolia.com/docsearch/).
|
114 |
|
115 | ## [CodeSandbox Examples](https://github.com/reactstrap/code-sandbox-examples)
|
116 |
|
117 | Here are some ready-to-go examples for [CodeSandbox](https://codesandbox.io/) that you can experiment with.
|
118 |
|
119 | https://github.com/reactstrap/code-sandbox-examples
|
120 |
|
121 | ## [Contributing](CONTRIBUTING.md)
|
122 |
|
123 | ## Development
|
124 |
|
125 | Install dependencies:
|
126 |
|
127 | ```sh
|
128 | yarn install
|
129 | ```
|
130 |
|
131 | Run examples at [http://localhost:8080/](http://localhost:8080/) with webpack dev server:
|
132 |
|
133 | ```sh
|
134 | yarn start
|
135 | ```
|
136 |
|
137 | Run tests & coverage report:
|
138 |
|
139 | ```sh
|
140 | yarn cover
|
141 | ```
|
142 |
|
143 | Watch tests:
|
144 |
|
145 | ```sh
|
146 | yarn test
|
147 | ```
|
148 |
|
149 | ## Releasing
|
150 |
|
151 | Release branches/versioning/notes will be automatically created and maintained by the [release-please](https://github.com/googleapis/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/.
|
152 |
|
153 | ## In the wild
|
154 |
|
155 | Organizations and projects using `reactstrap`
|
156 |
|
157 | - [airframe-react](https://github.com/0wczar/airframe-react) - [demo](http://dashboards.webkom.co/react/airframe/) - Airframe provides all the components a developer needs to build data-intensive web apps using React.
|
158 | - [component-template](https://reactstrap.github.io/component-template/)
|
159 | - [video-react](https://video-react.github.io/)
|
160 | - [CoreUI-Free-Bootstrap-Admin-Template](https://github.com/mrholek/CoreUI-Free-Bootstrap-Admin-Template) - [demo](http://coreui.io/demo/React_Demo/#/)
|
161 | - [Admin dashboard example app built with reactstrap](https://github.com/reduction-admin/react-reduction) - [demo](https://reduction-admin.firebaseapp.com/)
|
162 | - [DevExtreme React Grid](https://devexpress.github.io/devextreme-reactive/react/grid/) - It's a stateless data grid built on top of `reactstrap` with paging, sorting, filtering, grouping, selection, editing and virtual scrolling features.
|
163 | - [DevExtreme React Chart](https://devexpress.github.io/devextreme-reactive/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.
|
164 | - [reactstrap-scrollspy](https://github.com/keidrun/reactstrap-scrollspy/) - [demo](https://keidrun.github.io/reactstrap-scrollspy/)
|
165 | - [formstrap](https://github.com/pedox/formstrap/) - [demo](https://pedox.github.io/formstrap/) - Let your `reactstrap` input component integrate seamlessly using `Formik`
|
166 | - [Jimu UI](https://developers.arcgis.com/experience-builder/api-reference/jimu-ui/) - [demo](https://developers.arcgis.com/experience-builder/storybook/?path=/story/welcome--page) - The UI library for [ArcGIS Experience Builder](https://developers.arcgis.com/experience-builder/) mapping platform.
|
167 |
|
168 | Submit a PR to add to this list!
|
169 |
|
170 | 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!
|