UNPKG

7.38 kBMarkdownView Raw
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
7Stateless React Components for Bootstrap 5.
8
9If you're using Bootstrap 4, you'll need to use [Reactstrap v8](https://deploy-preview-2356--reactstrap.netlify.app/)
10
11## Getting Started
12
13Follow 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 ```
18npx create-react-app my-app
19cd my-app/
20npm start
21```
22or, if npx (Node >= 6 and npm >= 5.2 ) not available
23
24```
25npm install -g create-react-app
26
27create-react-app my-app
28cd my-app/
29npm start
30```
31
32Then 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
36Install reactstrap and Bootstrap from NPM. Reactstrap does not include Bootstrap CSS so this needs to be installed as well:
37
38```
39npm i bootstrap
40npm i reactstrap react react-dom
41```
42
43Import Bootstrap CSS in the ```src/index.js``` file:
44
45```js
46import 'bootstrap/dist/css/bootstrap.css';
47```
48
49Import required reactstrap components within ```src/App.js``` file or your custom component files:
50
51```js
52import { Button } from 'reactstrap';
53```
54
55Now you are ready to use the imported reactstrap components within your component hierarchy defined in the render
56method. Here is an example [`App.js`](https://gist.github.com/Thomas-Smyth/006fd507a7295f17a8473451938f9935) redone
57using reactstrap.
58
59### Dependencies
60
61##### Required Peer Dependencies
62
63These 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
70This 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
72There are a few core concepts to understand in order to make the most out of this library.
73
741. 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
972. 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
111https://reactstrap.github.io
112
113Documentation search is powered by [Algolia's DocSearch](https://community.algolia.com/docsearch/).
114
115## [CodeSandbox Examples](https://github.com/reactstrap/code-sandbox-examples)
116
117Here are some ready-to-go examples for [CodeSandbox](https://codesandbox.io/) that you can experiment with.
118
119https://github.com/reactstrap/code-sandbox-examples
120
121## [Contributing](CONTRIBUTING.md)
122
123## Development
124
125Install dependencies:
126
127```sh
128yarn install
129```
130
131Run examples at [http://localhost:8080/](http://localhost:8080/) with webpack dev server:
132
133```sh
134yarn start
135```
136
137Run tests & coverage report:
138
139```sh
140yarn cover
141```
142
143Watch tests:
144
145```sh
146yarn test
147```
148
149## Releasing
150
151Release 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
155Organizations 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
168Submit a PR to add to this list!
169
170Looking to build, document and publish reusable components built on top of `reactstrap`? Consider forking https://github.com/reactstrap/component-template to kickstart your project!