Using React Bootstrap’s Row and Col for Responsive Layouts Without Custom CSS
Learn how React Bootstrap’s Row and Col components replace custom media queries with declarative, breakpoint‑specific props for responsive layouts.
11 Dec 2025, 02:29 UTC

Problem: Writing media queries for every layout change
When building a React UI, developers often reach for custom CSS or inline styles to make components stack on small screens and sit side‑by‑side on larger ones. This approach leads to duplicated breakpoint logic, harder maintenance, and a mismatch between the design system and the actual markup.
Thesis: React Bootstrap’s Row and Col components let you declare responsive behavior directly in JSX, leveraging Bootstrap’s flexbox grid without leaving the component file.
How the grid works
The Row component renders a <div className=\"row\"> which activates Bootstrap’s flex container. Each Col inside receives column classes based on the props you pass. If you omit a prop for a breakpoint, Bootstrap falls back to its default behavior: the column takes up the remaining space or expands to full width on extra‑small screens.
Worked example: a card list that adapts
import { Row, Col } from 'react-bootstrap';
import Card from './Card'; // your own card component
export function CardGallery() {
return (
{/* g-4 adds gap utility */}
);
}
What happens:
- On
md(≥768px) and larger screens eachColgetscol-md-4, so three cards fit per row (4+4+4 = 12). The fourth card wraps to a new line. - On
lg(≥992px) the props change tocol-lg-3, allowing four cards per row. - On extra‑small screens (
xs) noxsprop is supplied, so each column defaults tocol(flex‑grow: 1) and then tocol-12because the missing breakpoint triggers full width, causing the cards to stack vertically.
Trade‑off: reliance on Bootstrap’s breakpoint values
The grid’s behavior is tightly coupled to Bootstrap’s Sass variables ($grid-breakpoints). If you customize those variables (e.g., change the md threshold) or accidentally load a mismatched Bootstrap version, the md, lg, etc., props will no longer map to the expected widths. Over‑specifying props for every breakpoint can also reduce the grid’s ability to share remaining space, making the layout less fluid when content changes.
Actionable guidance
- Start with
<Col>(no props) for equal‑width columns; add responsive props only when you need a specific width at a breakpoint. - Import the Bootstrap v5 CSS that matches the version of
react-bootstrapyou installed (e.g.,import 'bootstrap/dist/css/bootstrap.min.css';). - Verify the layout by resizing the browser or using Chrome DevTools’ device toolbar. Inspect a
Colelement to confirm it contains the expected classes likecol-md-4. - For regression safety, write a simple test with React Testing Library that asserts the presence of those class names after rendering.
By treating the grid as a declarative layout tool rather than a styling hook, you keep your JSX readable, reduce CSS duplication, and let Bootstrap handle the responsive math.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.