Building Responsive Layouts with React‑Bootstrap’s Grid System
Learn how to use React‑Bootstrap’s Row and Col components to create responsive, breakpoint‑aware layouts with a concrete code example and common pitfalls to avoid.
04 Oct 2026, 06:31 UTC

Use the Grid to get fluid, breakpoint‑aware columns
React‑Bootstrap’s Row and Col components implement a flex‑based 12‑column grid. By passing breakpoint props (xs, sm, md, lg, xl) you can define how many columns a element should span and whether it should be offset, all without writing custom media queries.
Worked example: a card that shifts from full‑width on phones to two‑column on tablets
import { Container, Row, Col, Card } from 'react-bootstrap';
function ResponsiveCards() {
return (
{/* g-4 adds a 1.5rem gutter */}
Feature A
Short description that stacks on small screens.
Feature B
Short description that stacks on small screens.
);
}
export default ResponsiveCards;
What happens:
- On extra‑small (
xs) viewports eachColgetsspan:12→ full width, stacking vertically. - At the medium (
md) breakpoint and above the props change tospan:6→ each card occupies half the row, sitting side‑by‑side. - The
Containeradds horizontal padding and a max‑width that prevents the grid from touching the viewport edges.
How the mechanism works
Row renders a div with display:flex. Col translates the breakpoint props into CSS classes like col-12 and col-md-6 (React‑Bootstrap v2 uses flex‑based utility classes). The browser applies those classes, which set flex-basis and margin-left for offsets, giving the desired layout.
Limits and common mistakes
Even though the grid is powerful, a few pitfalls can break the layout:
- Mixing inline widths or custom flex rules – Adding
style={{ width: '50%' }}or customflexproperties on the sameColconflicts with the grid’s utility classes, often causing unexpected wrapping or overflow. - Forgetting to reset a prop at a higher breakpoint – The grid follows a mobile‑first approach. If you set
xs={{ span: 8 }}but never override it formd, the column will stay 8‑column wide on medium and large screens, potentially leaving too much empty space. - Omitting the
Container– Without it the grid extends edge‑to‑edge. On narrow viewports this can cause horizontal scroll because the gutters are not offset by the container’s padding. - Incorrect nesting – Placing a
Rowinside aColis fine, but you must not add extra padding or margin to the inner row that would double the gutter. Use the gutter utility (g-*) on the inner row only if you need a different spacing.
Practical verification
To confirm the behavior:
- Render the example above in a local React app with React‑Bootstrap installed.
- Open the browser’s developer tools and inspect a
Colelement. You should see classes such ascol-12 col-md-6. - Resize the viewport past the
mdbreakpoint (≈768px) and observe the cards switch from stacked to side‑by‑side. - For nesting, place a
Rowwith twoCol xs={6}inside an outerColand verify that the inner columns do not overflow the outer column’s bounds.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.