Flex columns ​

The flex columns layout provides a set of classes to arrange content in rows with Flexbox.

Flex columns use numbered widths on a 12-unit scale, similar to Bootstrap's grid. However, Bootstrap creates gutters with padding on each column, while Graupl uses the CSS gap property to space items apart. Flexbox sizes each row independently, so the gaps can fall in different places from row to row. Use the Columns layout when gaps need to line up across rows.

Base class ​

The .flex-columns class puts a container's direct children in a row. The items can grow to fill the available width and wrap onto another row if there isn't enough room.

Column widths ​

Use .col-1 through .col-12 on a direct child to size it in twelfths of the container's width, with room for the gaps between items. Add .fill alongside the width class to let an item grow into the space left on its row.

Responsive variants ​

Use a screen-size prefix on the item to change its width at that breakpoint and above. With col-6 lg:col-4, an item uses six units by default and four from the large screen breakpoint.

Graupl applies a single-column fallback to unprefixed width classes when the flex container is up to 575px wide. A responsive width class such as lg:col-4 can override that fallback.

See responsive utility classes for the available prefixes.

Variants ​

By default, no theme variants are generated.

If you are compiling your own version of Graupl, you can set the flex columns module’s $themeable variable to true to generate the .primary, .secondary, and .tertiary variants.

Custom Properties ​

The following custom properties can be used to customize the flex columns layout:

PropertyDescriptionDefault Value
--graupl-flex-columns-row-gapThe gap between the rows of the flex columns.var(--graupl-columns-row-gap)
--graupl-flex-columns-column-gapThe gap between the columns of the flex columns.var(--graupl-columns-column-gap)
--graupl-flex-columns-sizeThe size of a column.auto
--graupl-flex-columns-max-widthThe maximum width of a column.unset
--graupl-flex-columns-container-typeThe container type applied to the flex columns component.inline-size
--graupl-flex-columns-backgroundThe background of the flex columns component.No default
--graupl-flex-columns-colorThe text color of the flex columns component.No default

Sass variables ​

The following Sass variables can be used to customize the generation of the flex columns layout:

VariableDescriptionDefault Value
$selector-baseThe base selector for the component."."
$modifier-selector-baseThe base selector for component modifiers."."
$generate-base-theme-mapFlag to generate the base theme map.true
$themeableFlag to generate theme modifiers.false
$screen-awareEnables screen-aware column variants.true
$theme-awareEnables theme-aware column variants.false
$scheme-awareEnables scheme-aware column variants.false
$state-awareEnables state-aware column variants.false
$container-awareEnables container-aware column variants.true
$force-single-columnsFlag to enable forced single column layout on small screens.true
$flex-columns-selector-baseThe base selector for the flex columns component."."
$flex-columns-selectorThe selector for the flex columns component."flex-columns"
$flex-columns-theme-selector-baseThe selector base for flex columns theme modifiers."."
$flex-columns-theme-selector-prefixThe flex columns theme modifier selector prefix.""
$flex-columns-column-selector-baseThe base selector for the column class."."
$flex-columns-column-selectorThe selector for the column class."col-"
$flex-columns-fill-selector-baseThe base selector for the fill class."."
$flex-columns-fill-selectorThe selector for the fill class."fill"
$flex-columns-screen-aware-selector-prefixPrefix to the screen-aware portion of column selectors.""
$flex-columns-screen-aware-selector-suffixSuffix to the screen-aware portion of column selectors.""
$flex-columns-screen-aware-selector-separatorSeparator inserted for screen-aware column selectors."\\:"
$flex-columns-theme-aware-selector-prefixPrefix to the theme-aware portion of column selectors.""
$flex-columns-theme-aware-selector-suffixSuffix to the theme-aware portion of column selectors."-theme"
$flex-columns-theme-aware-selector-separatorSeparator inserted for theme-aware column selectors."\\:"
$flex-columns-scheme-aware-selector-prefixPrefix to the scheme-aware portion of column selectors.""
$flex-columns-scheme-aware-selector-suffixSuffix to the scheme-aware portion of column selectors."-mode"
$flex-columns-scheme-aware-selector-separatorSeparator inserted for scheme-aware column selectors."\\:"
$flex-columns-state-aware-selector-prefixPrefix to the state-aware portion of column selectors.""
$flex-columns-state-aware-selector-suffixSuffix to the state-aware portion of column selectors.""
$flex-columns-state-aware-selector-separatorSeparator inserted for state-aware column selectors."\\:"
$flex-columns-container-aware-selector-prefixPrefix to the container-aware portion of column selectors."cq\\:"
$flex-columns-container-aware-selector-suffixSuffix to the container-aware portion of column selectors.""
$flex-columns-container-aware-selector-separatorSeparator inserted for container-aware column selectors."\\:"
$flex-columns-min-countThe minimum number of columns used to generate .col-# classes.1
$flex-columns-max-countThe maximum number of columns used to generate .col-# classes.12
$flex-columns-sizeThe default size of a column.auto
$flex-columns-max-widthThe default maximum width of a column.unset
$flex-columns-container-typeThe container type applied to the flex columns component."inline-size"
$flex-columns-theme-mappingsMap of properties/shades for flex columns themes.()
$flex-columns-theme-mapExpanded map of properties/colors/shades.()