Is it possible to add an extra size to react bootstrap?
Right now the bootstrap sizes are as follows:
WPW Container Max-Width
sx < 576px - none
sm > 567px - 540px
md > 768px - 720px
lg > 992px - 960px
xl > 1200px - 1140px
xxl > 1400px - 1320px
I would like to add another one like
xxl > 1580px – 1500px
I want to add this because I want a container with a max width of 1500px and be able to divide columns of the row in such a way as to fit 5 columns on a row.
So far I added this to my CSS
@media (min-width: 1580px) {
.container,
.container-lg,
.container-md,
.container-sm,
.container-xl,
.container-xxl {
max-width: 1500px;
}
}
This only makes the container bigger, doesn’t adjust the col sizes and if I use xxl={2}
or xxl={2.2}
I still get 4 items/row.
2
Answers
In Bootstrap 5, the grid system is based on flex containers and flex items. If you want to customize the grid system for an additional breakpoint, you can create a custom CSS class for the new breakpoint and apply it to the specific elements.
Here’s an example of how you can create a custom class for a new breakpoint and use it with React Bootstrap:
CSS Code:
Then, in your React component, you can use this custom class:
As explained here, there is no way to get react-bootstrap attributes to recognize the additional breakpoint (ie:
xxxl={5}
)However, you can add the extra breakpoint to Bootstrap using SASS, and then refer the appropriate Bootstrap
row-cols-{breakpoint}-{size}
class asclassName
.https://codeply.com/p/z7Oqx8giVL
Here’s how to generate the extra xxxl grid breakpoint using SASS. Just adding container size changes in CSS won’t be enough…
SASS:
Markup:
Demo