Breakpoints
Use mobile-first responsive utilities to adapt layouts across screen sizes.
Syntax
Responsive utilities are mobile-first. Classes without a breakpoint apply to all screen sizes.
Breakpoint classes apply from the defined breakpoint and up.
<div class="col-12 col-md-6 col-lg-4">Responsive column</div>This means:
.col-12 applies to all screen sizes
.col-md-6 applies from md and up
.col-lg-4 applies from lg and upResponsive utilities follow a predictable naming pattern.
[property]-[breakpoint]-[value]Examples:
.d-md-flex
.col-lg-6
.mt-xl-4
.px-md-3
.gap-lg-2
.gap-lg-2.5
.space-y-md-2.5
.flex-md-row
.justify-content-lg-center
.align-items-xl-startBreakpoint reference
css-utils provides the following default breakpoints:
| Breakpoint | Class infix | Min width | Example |
|---|---|---|---|
| Small | sm |
576px |
.d-sm-flex |
| Medium | md |
768px |
.d-md-flex |
| Large | lg |
992px |
.d-lg-flex |
| Extra large | xl |
1200px |
.d-xl-flex |
| Extra extra large | xxl |
1400px |
.d-xxl-flex |
Sass configuration
Configure the breakpoints map through the theme before importing utilities. Keep its entries in ascending width order: their generation order determines precedence when several rules match.
@use '@oardi/css-utils/theme' with (
$theme: (
breakpoints: (
sm: 36rem,
md: 48rem,
lg: 62rem,
xl: 75rem,
xxl: 87.5rem,
),
)
);
@use '@oardi/css-utils';Sass mixin
Use the published breakpoint mixins when custom styles need to share the library’s configured breakpoints:
@use '@oardi/css-utils/breakpoints' as bp;
.custom-layout {
@include bp.media-up(md) {
display: grid;
}
@include bp.media-below(md) {
display: none;
}
}The mixin reads the same theme map as the responsive utilities and reports an error for unknown breakpoint names.
Responsive behavior
Rules use minimum widths, so a matching variant remains active at larger sizes until a later breakpoint overrides it. Class order in the markup does not change this precedence. Use one value per utility family at each breakpoint.
Responsive display
Use responsive display utilities to show, hide or change the display behavior of elements at specific breakpoints.
<div class="d-block d-md-none">Visible below md</div>
<div class="d-none d-md-block">Visible from md and up</div>Responsive grid
Use responsive grid column utilities to change the column width across breakpoints.
<div class="grid">
<div class="col-12 col-md-6 col-lg-4">...</div>
<div class="col-12 col-md-6 col-lg-4">...</div>
<div class="col-12 col-md-6 col-lg-4">...</div>
</div>Responsive spacing
Use responsive spacing utilities to change margin, padding, gap or direct-child spacing at specific
breakpoints. Whole and half steps from 0 through 5 are available.
<div class="p-2 p-md-3 p-lg-4">Responsive padding</div>Axis and direction utilities also support breakpoints:
<div class="px-2 px-md-3 px-lg-4">Responsive horizontal padding</div>
<div class="mt-2 mt-md-3 mt-lg-4">Responsive margin top</div>
<div class="d-flex gap-1.5 gap-md-2.5">Responsive gap</div>
<div class="space-y-1.5 space-y-md-2.5">Responsive child spacing</div>Responsive flex
Use responsive flex utilities to change layout direction and alignment across breakpoints.
<div class="d-flex flex-column flex-md-row gap-2">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>You can also combine responsive flex alignment utilities:
<div
class="d-flex justify-content-start justify-content-md-center align-items-start align-items-md-center">
...
</div>Recipes
Content and sidebar
Let the sidebar move beside the main content from md upward.
<div class="grid">
<div class="col-12 col-md-8">Content</div>
<div class="col-12 col-md-4">Sidebar</div>
</div>Comfortable section spacing
Increase padding when more viewport space becomes available.
<section class="bg-primary px-2 px-md-3 px-lg-4 py-3 py-lg-5">Project overview</section>