AskHandle

AskHandle Blog

Embracing React Bootstrap: A Symphony of Simplicity and Style

September 4, 2025Jessy Chan3 min read

Embracing React Bootstrap: A Symphony of Simplicity and Style

React Bootstrap is a library of React components that use the popular Bootstrap framework. It allows for easy integration of Bootstrap's responsive design system into React applications, resulting in a consistent user experience. Here are some key points to help you get started with React Bootstrap.

Getting Started with React Bootstrap

Installation

To use React Bootstrap in your project, you need to install it via npm or yarn:

bash
1# Using npm
2npm install react-bootstrap bootstrap
3
4# Using yarn
5yarn add react-bootstrap bootstrap

Importing Bootstrap Styles

Include Bootstrap’s CSS stylesheet to utilize its design components. Add the following import statement in your main index.js or App.js file:

javascript
1import 'bootstrap/dist/css/bootstrap.min.css';

Using Components

React Bootstrap provides a wide range of pre-built components that follow Bootstrap's naming convention. Here are some examples.

Buttons

Buttons are crucial in any application. React Bootstrap makes them easy to implement and customize:

javascript
1import React from 'react';
2import Button from 'react-bootstrap/Button';
3
4function App() {
5    return (
6        <div>
7            <Button variant="primary">Primary Button</Button>
8            <Button variant="secondary">Secondary Button</Button>
9        </div>
10    );
11}
12
13export default App;

Alerts

Creating alert messages with custom styling is straightforward:

javascript
1import React, { useState } from 'react';
2import Alert from 'react-bootstrap/Alert';
3import Button from 'react-bootstrap/Button';
4
5function DismissibleAlert() {
6    const [show, setShow] = useState(true);
7
8    if (show) {
9        return (
10            <Alert variant="success" onClose={() => setShow(false)} dismissible>
11                <Alert.Heading>Well done!</Alert.Heading>
12                <p>You have successfully read this alert message.</p>
13            </Alert>
14        );
15    }
16    return <Button onClick={() => setShow(true)}>Show Alert</Button>;
17}
18
19export default DismissibleAlert;

Cards

Cards present content stylishly and flexibly:

javascript
1import React from 'react';
2import Card from 'react-bootstrap/Card';
3import Button from 'react-bootstrap/Button';
4
5function ExampleCard() {
6    return (
7        <Card style={{ width: '18rem' }}>
8            <Card.Img variant="top" src="holder.js/100px180" />
9            <Card.Body>
10                <Card.Title>Card Title</Card.Title>
11                <Card.Text>
12                    Some quick example text to build on the card title.
13                </Card.Text>
14                <Button variant="primary">Go somewhere</Button>
15            </Card.Body>
16        </Card>
17    );
18}
19
20export default ExampleCard;

Customization and Theming

React Bootstrap is easily customizable. You can use Sass to override Bootstrap’s default variables. First, install Sass:

bash
1npm install sass
2# or
3yarn add sass

Create a custom.scss file and import Bootstrap with your customizations:

scss
1// custom.scss
2$theme-colors: (
3  "primary": #ff6f61,  // Changing primary color
4  "secondary": #6c757d // Changing secondary color
5);
6
7@import "~bootstrap/scss/bootstrap";

Import the custom.scss file in your main index.js or App.js:

javascript
1import './custom.scss';

Responsive Grid System

React Bootstrap supports a responsive grid system, which is useful for structured layouts:

javascript
1import React from 'react';
2import Container from 'react-bootstrap/Container';
3import Row from 'react-bootstrap/Row';
4import Col from 'react-bootstrap/Col';
5
6function GridLayout() {
7    return (
8        <Container>
9            <Row>
10                <Col>1 of 2</Col>
11                <Col>2 of 2</Col>
12            </Row>
13            <Row>
14                <Col>1 of 3</Col>
15                <Col>2 of 3</Col>
16                <Col>3 of 3</Col>
17            </Row>
18        </Container>
19    );
20}
21
22export default GridLayout;

Form Handling

Handling forms in React Bootstrap is user-friendly. Here's how to create a form with input fields:

javascript
1import React, { useState } from 'react';
2import Form from 'react-bootstrap/Form';
3import Button from 'react-bootstrap/Button';
4
5function ExampleForm() {
6    const [email, setEmail] = useState('');
7    const [password, setPassword] = useState('');
8
9    const handleSubmit = (event) => {
10        event.preventDefault();
11        // handle form submission logic
12    };
13
14    return (
15        <Form onSubmit={handleSubmit}>
16            <Form.Group controlId="formBasicEmail">
17                <Form.Label>Email address</Form.Label>
18                <Form.Control type="email" placeholder="Enter email" value={email} onChange={e => setEmail(e.target.value)} />
19            </Form.Group>
20            <Form.Group controlId="formBasicPassword">
21                <Form.Label>Password</Form.Label>
22                <Form.Control type="password" placeholder="Password" value={password} onChange={e => setPassword(e.target.value)} />
23            </Form.Group>
24            <Button variant="primary" type="submit">
25                Submit
26            </Button>
27        </Form>
28    );
29}
30
31export default ExampleForm;

Advanced Usage: Modals

Modals are useful for displaying content without disrupting the user’s workflow. Implementing them in React Bootstrap is easy:

javascript
1import React, { useState } from 'react';
2import Modal from 'react-bootstrap/Modal';
3import Button from 'react-bootstrap/Button';
4
5function ExampleModal() {
6    const [show, setShow] = useState(false);
7
8    const handleClose = () => setShow(false);
9    const handleShow = () => setShow(true);
10
11    return (
12        <>
13            <Button variant="primary" onClick={handleShow}>
14                Launch demo modal
15            </Button>
16
17            <Modal show={show} onHide={handleClose}>
18                <Modal.Header closeButton>
19                    <Modal.Title>Modal heading</Modal.Title>
20                </Modal.Header>
21                <Modal.Body>Woohoo, you're reading this text in a modal!</Modal.Body>
22                <Modal.Footer>
23                    <Button variant="secondary" onClick={handleClose}>
24                        Close
25                    </Button>
26                    <Button variant="primary" onClick={handleClose}>
27                        Save Changes
28                    </Button>
29                </Modal.Footer>
30            </Modal>
31        </>
32    );
33}
34
35export default ExampleModal;

React Bootstrap simplifies the process of creating visually appealing and responsive applications. Features like buttons, alerts, forms, and modals enable developers to efficiently create practical user interfaces.