Layout
Learn how to position elements on the screen, change their size, alignment, borders, and spacing.
Layout System
We encourage you to use flex layout when possible. Use these classes to change the display property of your components:
| CSS Class | Added Property |
|---|---|
.d-flex |
display: flex !important |
.d-inline-flex |
display: inline-flex !important |
.d-block |
display: block !important |
.d-inline-block |
display: inline-block !important |
.d-inline |
display: inline !important |
.d-grid |
display: grid !important |
.d-table |
display: table !important |
.d-contents |
display: contents !important |
.hidden |
display: none !important |
Add the following classes to the elements with .d-flex or .d-inline-flex to add some additional properties. Please refer to the Responsiveness page for responsive classes.
| CSS Class | Effect | Result |
|---|---|---|
.flex-column |
Creates a vertical stack | Item 1 Item 2 Item 3 |
.flex-row |
Creates a horizontal stack (default behaviour) | Item 1 Item 2 Item 3 |
.flex-row-reverse |
Creates a reversed horizontal stack | Item 1 Item 2 Item 3 |
.flex-column-reverse |
Creates a reversed vertical stack | Item 1 Item 2 Item 3 |
.flex-wrap |
Forces wrapping of the items in a stack (they don’t wrap by default) | Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 |
.flex-nowrap |
Keeps all items on one line (default behaviour) | Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 |
.align-items-start |
Aligns items to the top (or to the left if .flex-column is applied) |
|
.align-items-center |
Aligns items to the center | |
.align-items-end |
Aligns items to the bottom (or to the right if .flex-column is applied) |
|
.align-items-baseline |
Aligns items by the baseline of their text | TitleSubtitle |
.align-items-stretch |
Stretches items to fill the container height (default behaviour) | |
.justify-content-start |
Aligns items to the top/left | Item Item Item |
.justify-content-center |
Aligns items to the center | Item Item Item |
.justify-content-end |
Aligns items to the end/bottom | Item Item Item |
.justify-content-around |
Spreads items around | Item Item Item |
.justify-content-between |
Spreads items between | Item Item Item |
Add these classes to the child elements of .d-flex or .d-inline-flex to add some additional properties:
| CSS Class | Effect | Result |
|---|---|---|
.flex-grow |
Forces the element to take all available space | Item .flex-grow |
.flex-no-grow |
Stops the element from growing (default behaviour; use it to reset .flex-grow at a breakpoint, e.g. .flex-grow.flex-md-no-grow) |
.flex-no-grow .flex-grow |
.flex-no-shrink |
Prevents the element from shrinking | .flex-no-shrink .flex-grow |
.flex-shrink |
Lets the element shrink when there isn't enough space (default behaviour) | Item .flex-shrink with a long label |
.flex-basis-full |
Sets the starting width to 100% (wraps onto its own line with .flex-wrap) |
100% Item Item |
.flex-basis-half |
Sets the starting width to 50% | 50% Item |
.flex-basis-third |
Sets the starting width to 33.333% | 33% Item |
.flex-no-basis |
Sets the starting width to 0, so .flex-grow items share the space equally regardless of their content |
Short Much longer label |
.align-self-start |
Aligns this item to the top (overrides the container's align-items) |
.align-self-start |
.align-self-center |
Aligns this item to the center | .align-self-center |
.align-self-end |
Aligns this item to the bottom | .align-self-end |
.align-self-stretch |
Stretches this item to the container height | .align-self-stretch |
.order-first |
Moves the element to the start, e.g. .order-md-first to reorder from a breakpoint |
Item 1 Item 2 Item 3 (.order-first) |
Use these classes to align inline elements:
| CSS Class | Effect | Result |
|---|---|---|
.vat |
Aligns inline element to the top | Text top aligned text |
.vam |
Aligns inline element to the middle | Text middle aligned text |
.vab |
Aligns inline element to the bottom | Text bottom aligned text |
Grid & Gap
Use .d-grid with a column class to lay out items in equal-width columns. Columns don't overflow: long content wraps inside its column.
Columns
| CSS Class | Effect | Result |
|---|---|---|
.grid-cols-1 |
1 equal column | 1 2 |
.grid-cols-2 |
2 equal columns | 1 2 3 4 |
.grid-cols-3 |
3 equal columns | 1 2 3 4 5 6 |
.grid-cols-4 |
4 equal columns | 1 2 3 4 |
Column Span
Add these classes to the child elements of a grid.
| CSS Class | Effect | Result |
|---|---|---|
.col-span-1 |
Item spans 1 column | .col-span-1 1 2 |
.col-span-2 |
Item spans 2 columns | .col-span-2 1 |
.col-span-3 |
Item spans 3 columns | .col-span-3 |
.row-span-2 |
Item spans 2 rows | .row-span-2 1 2 |
.place-content-center |
Centers the grid content inside the container (add to the grid) | Item |
Gap
Gap adds space between the children of a grid or flex container, never around the outer edges. It uses the same scale as margins and paddings.
- There is no
.gap-0: remove the class instead - Prefer gap for repeated items (lists of cards, chips, rows) and margins for one-off spacing
| CSS Class | Size | Result |
|---|---|---|
.gap-4 |
4px | |
.gap-8 |
8px | |
.gap-12 |
12px | |
.gap-16 |
16px | |
.gap-24 |
24px | |
.gap-40 |
40px | |
.gap-80 |
80px |
| CSS Class | Effect | Result |
|---|---|---|
.gap-x-24 |
Gap between columns only | 1 2 3 4 |
.gap-y-24 |
Gap between rows only | 1 2 3 4 |
Grid columns, spans and gaps are responsive. The breakpoint goes after the property name, and before the axis for gaps: .grid-cols-1.grid-md-cols-2.grid-lg-cols-3, .col-md-span-2, .gap-16.gap-md-24, .gap-md-x-16. See the Responsiveness page.
Sizes
All spacing for components and typography is done in 4-pixel increments. This 4px value forms the basic unit of measurement for spacing (with some exceptions).
Add size classes to block elements to change their size.
| CSS Class | Result |
|---|---|
.size-4 |
|
.size-8 |
|
.size-12 |
|
.size-14 |
|
.size-16 |
|
.size-20 |
|
.size-24 |
|
.size-32 |
|
.size-40 |
|
.size-48 |
|
.size-56 |
|
.size-64 |
|
.size-72 |
|
.size-80 |
|
.size-96 |
|
.size-112 |
|
.w-100 |
100% width |
.w-auto |
.w-100.w-sm-auto: full width on phones, content width from 520px |
.h-100 |
100% height |
.h-auto |
Content height |
.minw-0 |
A flex child with |
.minh-0 |
The list's wrapper is a flex child. Without Without Header
With .minh-0 Header
|
Margins
You can add:
- margins for all sides of the element
- margins for individual sides: left, right, top, bottom
- only horizontal or vertical margins
- automatic margins (useful in flex layouts to push or center your components)
- zero margins (to override some default margins)
All margin classes start with the m prefix followed by side (a-, l-, r-, t-, b-, x-, y-), then the value (0, 8, 24, auto, etc). Example: .mb-12
Additionally, you can include the minimum breakpoint size when the class activates. Example: .mb-lg-12 – this class adds a 12px bottom margin on screens with a width of 880px and larger. Please refer to the Responsiveness page for responsive classes.
Margin Sides
| CSS Class | Sides | Result |
|---|---|---|
.ma-12 |
All | |
.ml-12 |
Left | |
.mr-12 |
Right | |
.mt-12 |
Top | |
.mb-12 |
Bottom | |
.mx-12 |
Horizontal | |
.my-12 |
Vertical |
Margin Sizes
| CSS Class | Size | Result |
|---|---|---|
.ml-0 |
0px | |
.ml-4 |
4px | |
.ml-8 |
8px | |
.ml-12 |
12px | |
.ml-16 |
16px | |
.ml-24 |
24px | |
.ml-40 |
40px | |
.ml-80 |
80px | |
.ml-auto |
auto |
Paddings
You can add:
- paddings for all sides of the element
- paddings for individual sides: left, right, top, bottom
- only horizontal or vertical paddings
- zero paddings (to override some default paddings)
All padding classes start with the p prefix followed by side (a-, l-, r-, t-, b-, x-, y-), then the value (0, 8, 24, etc). Example: .pb-12
Additionally, you can include the minimum breakpoint size when the class activates. Example: .pb-lg-12 – this class adds a 12px bottom padding on screens with a width of 880px and larger. Please refer to the Responsiveness page for responsive classes.
Padding Sides
| CSS Class | Sides | Result |
|---|---|---|
.pa-12 |
All | |
.pl-12 |
Left | |
.pr-12 |
Right | |
.pt-12 |
Top | |
.pb-12 |
Bottom | |
.px-12 |
Horizontal | |
.py-12 |
Vertical |
Padding Sizes
| CSS Class | Size | Result |
|---|---|---|
.pl-0 |
0px | |
.pl-4 |
4px | |
.pl-8 |
8px | |
.pl-12 |
12px | |
.pl-16 |
16px | |
.pl-24 |
24px | |
.pl-40 |
40px | |
.pl-80 |
80px |
Positioning
An absolutely positioned element is placed relative to its nearest positioned ancestor, so add .pos-rel to the container you want to position against.
| CSS Class | Added Property | Result |
|---|---|---|
.pos-rel |
position: relative; |
|
.pos-abs |
position: absolute; |
Text in the normal flow |
.pos-abs-centered |
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0); |
|
.center-x |
position: absolute;
top: auto;
left: 50%;
transform: translateX(-50%); |
|
.center-y |
position: absolute;
top: 50%;
left: auto;
transform: translateY(-50%); |
|
.center-xy |
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%); |
|
.pos-fix |
position: fixed; |
Fixed to the viewport (not shown) |
.pos-fix-t |
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 1; |
Fixed to the viewport (not shown) |
.pos-fix-b |
position: fixed;
right: 0;
left: 0;
bottom: 0;
z-index: 1; |
Fixed to the viewport (not shown) |
.sticky |
position: sticky;
top: 0;
z-index: 2; |
Sticky header Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 |
.sticky-bottom |
position: sticky;
bottom: 0;
z-index: 2; |
Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Sticky footer |
.sticky-left |
position: sticky;
left: 0;
z-index: 1; |
Sticky Col 1 Col 2 Col 3 Col 4 Col 5 |
.float-left |
float: left; |
Text wraps around the floated box on its right side and below it. |
.float-right |
float: right; |
Text wraps around the floated box on its left side and below it. |
Offsets
Use offsets with .pos-abs (or .sticky) to pin an element on top of other content, such as a badge, counter or button on an image or card. They use the spacing scale: 0, 4, 8, 12, 16, 24, 40, 80. .top-auto, .right-auto, .bottom-auto and .left-auto reset an offset to auto !important.
| CSS Class | Added Property | Result |
|---|---|---|
.top-{size} |
top: {size}px; |
.top-8.left-8 |
.right-{size} |
right: {size}px; |
.top-8.right-8 |
.bottom-{size} |
bottom: {size}px; |
.bottom-8.left-8 |
.left-{size} |
left: {size}px; |
.bottom-8.left-40 |
Borders
Borders are 0.5px wide (--border-width-base) in the neutral border color (--border-color-base). Add a color class to recolor a border.
| CSS Class | Effect | Result |
|---|---|---|
.ba |
Adds borders on all sides | |
.bt |
Adds top border | |
.br |
Adds right border | |
.bb |
Adds bottom border | |
.bl |
Adds left border | |
.ba-0 |
Removes all borders | |
.ba.bt-0 |
Adds borders to all sides except to the top | |
.ba.br-0 |
Adds borders to all sides except to the right | |
.ba.bb-0 |
Adds borders to all sides except to the bottom | |
.ba.bl-0 |
Adds borders to all sides except to the left | |
.ba.border-red |
Recolors the border red (--r2); works with any border class |
|
.ba.border-green |
Recolors the border green (--g2); works with any border class |
|
.ba.border-yellow |
Recolors the border yellow (--y2); works with any border class |
|
.ba.border-blue |
Recolors the border blue (--b2); works with any border class |
|
.rounded |
Rounds all borders (8px) | |
.rounded-top |
Rounds top borders (8px) | |
.rounded-bottom |
Rounds bottom borders (8px) | |
.rounded-left |
Rounds left borders (8px) | |
.rounded-right |
Rounds right borders (8px) | |
.rounded-double |
Rounds all borders (16px) | |
.rounded-top-double |
Rounds top borders (16px) | |
.rounded-bottom-double |
Rounds bottom borders (16px) | |
.rounded-left-double |
Rounds left borders (16px) | |
.rounded-right-double |
Rounds right borders (16px) | |
.rounded-sm |
Rounds all borders (8px) from 520px up; square on phones | |
.rounded-sm-{side} |
Rounds one side (8px) from 520px up: .rounded-sm-top, -right, -bottom, -left |
|
.rounded-sm-double |
Rounds all borders (16px) from 520px up | |
.rounded-sm-{side}-double |
Rounds one side (16px) from 520px up: .rounded-sm-top-double, -right-double, -bottom-double, -left-double |
|
.square-top |
Removes the top radius (overrides .rounded-* classes) |
|
.square-bottom |
Removes the bottom radius (overrides .rounded-* classes) |
|
.square-left |
Removes the left radius (overrides .rounded-* classes) |
|
.square-right |
Removes the right radius (overrides .rounded-* classes) |
|
.circle |
Makes a circle/pill | Rounded corners |
The .rounded-sm* classes only apply from the sm breakpoint (520px), which suits panels that run edge to edge on phones and become rounded cards on larger screens. They're the only responsive radius classes; there are no -md, -lg or -xl versions.
Shadows
Elevation comes from two shadow levels. .card already includes the medium shadow, so only add a shadow class to elements that aren't cards. In dark mode both levels switch to a darker shadow with a faint light edge.
| CSS Class | Effect | Result |
|---|---|---|
.shadow-md |
Card shadow (--card-shadow): resting surfaces such as cards and panels |
|
.shadow-lg |
Large shadow (--card-shadow-lg): raised surfaces such as popovers and dragged items |
|
.outline |
Adds a 2px ring in the primary color (--primary) without changing the element's size |
Images
| CSS Class | Effect | Result |
|---|---|---|
.img-cover |
Fills the container with the image (crops edges) | |
.img-contain |
Fits the image into the container (may leave transparent edges) | |
img.obj-cover |
Crops an <img> to fill its box (the <img> version of .img-cover) |
![]() |
img.obj-scale-down |
Shows the whole image, shrinking it only when it is larger than its box | ![]() |
Avatars
An avatar is a round profile picture: a .avatar container with a size class and an <img class="avatar-img"> inside. The image is cropped to a circle and gets a thin inner border. Without a photo, use the common-user icon, or any other icon, with .avatar-placeholder: it's centered on the theme's avatar background color and scales with the avatar.
.size-32.size-40.size-64placeholderView codeHide code
<!-- Photo -->
<div class="avatar size-40">
<img class="avatar-img" src="photo.jpg" alt="Jane Doe">
</div>
<!-- No photo: placeholder icon -->
<div class="avatar size-40" role="img" aria-label="Jane Doe">
<svg class="avatar-placeholder" aria-hidden="true"><use href="#common-user"/></svg>
</div>Scroll Areas & Overflow
| CSS Class | Effect | Result |
|---|---|---|
.scroll-y |
Scrolls the content vertically within the container |
|
.scroll-x |
Scrolls the content horizontally within the container | Item 1 Item 2 Item 3 |
.overflow-hidden |
Clips content that doesn't fit inside the container | |
.overflow-x-hidden |
Clips content horizontally only | A long line that gets clipped |
Visibility & Interaction
| CSS Class | Effect | Result |
|---|---|---|
.hidden |
Removes the element (display: none). See the Responsiveness page for .hidden-*-up / .hidden-*-down |
1 3 |
.invisible |
Hides the element but keeps its space (visibility: hidden) |
1 2 3 |
.visually-hidden |
Hides the element visually but keeps it available to screen readers, e.g. for labels of icon-only controls | Not visible (read by screen readers)This text is only read by screen readers |
.opacity-0 |
Fully transparent, still takes space and receives clicks | 1 2 3 |
.opacity-half |
50% transparent | 1 2 3 |
.opacity-1 |
Fully opaque, e.g. to reset .opacity-0 on hover or focus |
1 2 3 |
.hidden-touch |
Hidden on touch devices (when <body> doesn't have .non-touch), e.g. for hover-only hints |
|
.hidden-is-tabbing |
Hidden while the user navigates with the keyboard (body.is-tabbing). Press Tab to hide the example |
|
.non-printable |
Hidden when the page is printed | Not shown in print |
.pointer-events-none |
The element ignores clicks and hover; they go to whatever is underneath | |
.pointer-events-auto |
Turns clicks back on for a child of a .pointer-events-none element |
|
.hoverable |
Adds hover and pressed fills, a pointer cursor and a keyboard focus ring to clickable rows and tiles | |
.focusable |
Shows a keyboard focus ring on elements made focusable with tabindex="0". Press Tab to reach it |
Focusable box |
.transition-base |
Animates property changes (--transition-base: all .15s ease), e.g. hover fills |
Smooth hover |
.transform-none |
Removes any transform, e.g. to undo .center-xy's offset at a breakpoint |
|
.transition-fix |
Fixes Safari not clipping rounded corners on overflow: hidden elements with animated children |
No visible effect in other browsers |
Fade Edges
Fade the edges of a scroll area where content is cut off, so people can see there's more to scroll. Add .fade-out plus one or two directions. Only these combinations work: one side, .fade-up.fade-down, or .fade-left.fade-right.
The fade also fades the scroll area's own background, border and shadow, so put those on a wrapper. Don't fade an area with a sticky header or column: the fade covers it.
| CSS Class | Effect | Result |
|---|---|---|
.fade-out.fade-down |
Fades out the bottom edge, hinting there is more to scroll |
|
.fade-out.fade-up |
Fades out the top edge |
|
.fade-out.fade-up.fade-down |
Fades out both vertical edges |
|
.fade-out.fade-right |
Fades out the right edge | Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 |
.fade-out.fade-left |
Fades out the left edge | Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 |
.fade-out.fade-left.fade-right |
Fades out both horizontal edges | Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 Item 7 Item 8 |
Fade on Scroll
Add the script from the JS tab to fade only the edges where content is cut off. It updates the classes as people scroll, when the area or its content changes size, and when content is added. Scroll the boxes below: at the start only the end fades, in the middle both edges fade.
The script works on every .scroll-y, .scroll-x and .table-responsive element. Add data-scroll-fade to any other scroll area, or data-scroll-fade="off" to skip one.
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
View codeHide code
<div class="d-flex flex-wrap align-items-start gap-24">
<div class="d-flex flex-column bg-n1 rounded pa-8" style="width: 160px; height: 160px;">
<ul class="list-unstyled d-flex flex-column gap-8 scroll-y minh-0" tabindex="0" aria-label="Scrolling list">
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 1</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 2</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 3</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 4</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 5</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 6</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 7</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap text-center">Item 8</li>
</ul>
</div>
<div class="d-grid grid-cols-1 bg-n1 rounded pa-8" style="width: 240px;">
<ul class="list-unstyled d-flex gap-8 scroll-x" tabindex="0" aria-label="Scrolling row">
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 1</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 2</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 3</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 4</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 5</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 6</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 7</li>
<li class="px-8 py-4 rounded highlight text-md text-nowrap flex-no-shrink">Item 8</li>
</ul>
</div>
</div>
// Scroll fade: fades the edges of a scroll area where content is cut off.
// .fade-up / .fade-down when there's more content above / below, .fade-left / .fade-right sideways.
// Works on .scroll-y, .scroll-x, .table-responsive and [data-scroll-fade] elements.
// Skips elements that have .fade-out in the HTML, and data-scroll-fade="off".
function updateScrollFade(el) {
const up = el.scrollTop > 1;
const down = el.scrollTop + el.clientHeight < el.scrollHeight - 1;
// Fades work on one axis at a time: vertical wins when both are clipped
const vertical = up || down;
const left = !vertical && el.scrollLeft > 1;
const right = !vertical && el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
el.classList.toggle("fade-up", up);
el.classList.toggle("fade-down", down);
el.classList.toggle("fade-left", left);
el.classList.toggle("fade-right", right);
el.classList.toggle("fade-out", vertical || left || right);
}
function initScrollFade(el) {
if (el.classList.contains("fade-out") || el.dataset.scrollFade === "off") return;
const update = () => updateScrollFade(el);
el.addEventListener("scroll", update, { passive: true });
// Size changes: the area or its content resizes, or a hidden area (closed dialog, tab) appears
const resize = new ResizeObserver(update);
resize.observe(el);
[...el.children].forEach((child) => resize.observe(child));
// Content added or removed
new MutationObserver(update).observe(el, { childList: true, subtree: true, characterData: true });
update();
}
document.querySelectorAll(".scroll-y, .scroll-x, .table-responsive, [data-scroll-fade]").forEach(initScrollFade);
