Skip to main content
/
/
/
AutoCol

AutoCol

Create column layout based on available width

ReactCSS

Basic usage

.bf-autocol renders its children as (minimum) 300px wide columns with a 12px gap by default.
Drag the bottom right corner of the preview to test column behavior at different sizes.

Element
Element
Element
Element
Element
Element

Custom width and gap

Custom css property --bf-autocol-width controls column width, set to 150px here.
gap can also be overridden (if you prefer, var(--bfs8) can be used in place of 8px):

Element
Element
Element
Element
Element
Element

Inherited width and gap

You can change the default column and gap size for a container (or your entire app by selecting body instead) in your CSS:

CSS
/* applies to all .bf-autocol instances inside a .my-container wrapper */
.my-container {
  --bf-autocol-width: 250px;
  --bf-autocol-gap: 8px;
}

/* the above alone should work fine for any screen size,
but you can also specify larger values for xxl+ screens */
@media (min-width: 1920px) {
  .my-container {
    --bf-autocol-width: 350px;
    --bf-autocol-gap: 24px;
  }
}
Element
Element
Element
Element
Element
Element