Skip to main content
1.0.0Next5.1.05.0.35.0.25.0.15.0.04.0.94.0.84.0.73.2.03.1.03.0.13.0.02.1.12.0.101.0.0
Version: 1.0.0

Containers

A container limits content to a maximum width. Containers are most often used to hold grid rows, columns and components. Containers are the most basic layout element in Kognifai Design System. They have fluid-width (meaning they strive to be 100% wide all the time). They also add a default padding on the left and right side so we ensures a bit of breathing space between our content and the viewport edges.

While containers can be nested, most layouts do not require a nested container. If you think about your page as a hierarchy of boxes, the container is usually used outside your grid. See grid system for more details.

A bit simplified, it can look like this in HTML:

<div class="kx-container">
<div class="kx-row">
<div class="kx-col">
<div>Component</div>
</div>
<div class="kx-col">
<div>Component</div>
</div>
<div class="kx-col">
<div>Component</div>
</div>
</div>
</div>

Container Width

To understand the maximum width of containers, we need to be aware of the box sizing it uses. In CSS we usually define box-sizing with either:

  • content-box: It’s the default box-sizing, and gives you the default CSS box-sizing behaviour. If you set an element’s width to 100px, then the element’s content box will be 100 px wide, and the width of any border or padding will be added to the final rendered width.
  • border-box: It tells the browser to account for any borders and padding in the value your specify for width and height. If you set at element’s width to 100 px, that 100 px will include any border or padding you added, and the content box will shrink to absorb that extra width. This typically makes it easier to size elements.

A kx-container always uses content-box as it’s box sizing. This way we can easily adjust the outside padding of a container without affecting it’s maximum width.

To calculate the total width we can use this table:

Modifiermax-widthpadding-leftcontentpadding-righttotal
kx-container--mob-s62.5rem12px296px12px320px
kx-container--mob-m21.9375rem12px351px12px375px
kx-container--tab-s36rem12px576px12px600px
kx-container--tab-m46.5rem12px744px12px768px
kx-container--tab-l62.5rem12px1000px12px1024px
kx-container--ltp-s78.5rem12px1256px12px1280px
kx-container--ltp-m88.5rem12px1416px12px1440px
kx-container--dtp118.5rem12px1896px12px1920px

The class-names used to control max-width are modifiers, so they should always be used together with the base-class kx-container. Modifiers for container widths corresponds to out responsive breakpoints.

<div class="kx-container kx-container--tab-l">
<!-- Container will stretch but never become wider than "large tablet" -->
</div>

Container Alignment

Use spacing utilities to align the container left, center or right.

  • kx-mr--auto (aligns container to the left)
  • kx-mx--auto (aligns container to the center)
  • kx-ml--auto (aligns container to the right)
<div class="kx-container kx-container--tab-m kx-mr--auto">
<!-- Container will stretch but never become wider than "medium tablet" -->
</div>

Container tab-m + left alignment

<div class="kx-container kx-container--tab-m kx-mx--auto">
<!-- Container will stretch but never become wider than "medium tablet" -->
</div>

Container tab-m + center alignment

<div class="kx-container kx-container--tab-m kx-ml--auto">
<!-- Container will stretch but never become wider than "medium tablet" -->
</div>

Container tab-m + right alignment

To test how containers look in a page, please have a look at the template layout. Try also to open it as a standalone page and resize your browser.