@mastors/flexer
Complete flexbox utility system for the Mastors ecosystem
@mastors/flexer is a purpose-built SCSS package that provides a complete, production-ready flexbox utility class system. Every CSS flexbox property — from display and flex-direction through to place-self and order — is covered with utility classes, responsive breakpoint variants, and composable Sass mixins. It consumes @mastors/core for its token system and responsive engine.
sm:flex-col, lg:justify-between, etc.
Installation
Requires @mastors/core ≥ 1.0.0 and sass ≥ 1.80.0 as peer dependencies.
npm
npm install @mastors/flexerpnpm
pnpm add @mastors/flexeryarn
yarn add @mastors/flexerImport & Usage
Choose between a full CSS import (outputs all utility classes) or the Sass API (zero CSS output — mixins and generators only).
Full import — outputs all flexbox utility classes
// In your main stylesheet — after @mastors/core
@use "@mastors/core";
@use "@mastors/flexer";Load via Sass loadPaths (no bundler alias needed)
// vite.config.js / webpack.config.js
css: {
preprocessorOptions: {
scss: { loadPaths: ['node_modules'] }
}
}Import Sass mixins only (no utility CSS output)
@use "@mastors/flexer/scss/mixins/flex-container" as *;
@use "@mastors/flexer/scss/mixins/flex-item" as *;
@use "@mastors/flexer/scss/mixins/flex-center" as *;
.card-grid {
@include flex-container($wrap: wrap, $gap: 1.5rem);
}
.card {
@include flex-item($grow: 1, $basis: 280px);
}Package exports map
{
".": {
"sass": "./scss/index.scss",
"style": "./dist/mastors-flexer.css"
},
"./scss": "./scss/index.scss",
"./scss/*": "./scss/*"
}Display
Flex Display
Display ResponsiveEstablishes a flex formatting context on the element. Use flex for block-level and inline-flex for inline-level containers.
| Class | CSS output | When to use |
|---|---|---|
| .flex | display: flex | Block-level flex container — takes full width of parent |
| .inline-flex | display: inline-flex | Inline flex container — only as wide as its content |
<!-- Block flex container -->
<div class="flex">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
<!-- Inline flex — wraps tightly around children -->
<span class="inline-flex items-center gap-2">
<i class="fa-solid fa-star"></i>
<span>Inline badge</span>
</span>
<!-- Responsive: flex on all, column on mobile -->
<div class="flex md:flex">...</div>.flex — children laid out in a row by default
.inline-flex — hugs content
Inline flex badgeDirection & Wrapping
Flex Direction
Container ResponsiveControls the main axis — the direction items are placed in a flex container.
| Class | CSS output | Description |
|---|---|---|
| .flex-row | flex-direction: row | Left to right (default). Main axis is horizontal. |
| .flex-row-reverse | flex-direction: row-reverse | Right to left. Items appear in reverse order horizontally. |
| .flex-col | flex-direction: column | Top to bottom. Main axis is vertical. |
| .flex-col-reverse | flex-direction: column-reverse | Bottom to top. Items appear in reverse order vertically. |
<div class="flex flex-row gap-3">
<div>1</div><div>2</div><div>3</div>
</div>
<div class="flex flex-row-reverse gap-3">
<div>1</div><div>2</div><div>3</div>
</div>
<div class="flex flex-col gap-3">
<div>1</div><div>2</div><div>3</div>
</div>
<!-- Responsive: column on mobile, row on md+ -->
<div class="flex flex-col md:flex-row gap-4">
<aside>Sidebar</aside>
<main>Content</main>
</div>flex-row
flex-row-reverse
flex-col
flex-col-reverse
Flex Wrap
Container ResponsiveControls whether flex items wrap to the next line when they overflow the container's main axis.
| Class | CSS output | Description |
|---|---|---|
| .flex-wrap | flex-wrap: wrap | Items wrap to the next row/column when they overflow. |
| .flex-wrap-reverse | flex-wrap: wrap-reverse | Items wrap, but wrapped lines appear before the first line. |
| .flex-nowrap | flex-wrap: nowrap | No wrapping. Items stay on one line and may overflow (browser default). |
<!-- Items wrap naturally at container edge -->
<div class="flex flex-wrap gap-2">
<div>Item 1</div><div>Item 2</div><div>Item 3</div>
<div>Item 4</div><div>Item 5</div>
</div>
<!-- Wrap in reverse direction -->
<div class="flex flex-wrap-reverse gap-2">...</div>
<!-- Force single line (overflow possible) -->
<div class="flex flex-nowrap overflow-x-auto gap-2">...</div>flex-wrap — items wrap to next line
flex-nowrap — all on one line
Flex Flow
Container ResponsiveShorthand that sets both flex-direction and flex-wrap in a single class.
| Class | CSS output |
|---|---|
| .flex-flow-row-wrap | flex-flow: row wrap |
| .flex-flow-row-nowrap | flex-flow: row nowrap |
| .flex-flow-row-wrap-reverse | flex-flow: row wrap-reverse |
| .flex-flow-col-wrap | flex-flow: column wrap |
| .flex-flow-col-nowrap | flex-flow: column nowrap |
| .flex-flow-col-wrap-reverse | flex-flow: column wrap-reverse |
<!-- Column direction with wrapping -->
<div class="flex flex-flow-col-wrap gap-3" style="height:8rem">
<div>A</div><div>B</div><div>C</div><div>D</div>
</div>
<!-- Row + no wrap (single scroll line) -->
<div class="flex flex-flow-row-nowrap gap-3 overflow-x-auto">
<div>1</div><div>2</div><div>3</div>
</div>Item Sizing
Flex Grow
ItemControls how much a flex item grows to fill available free space in the container relative to its siblings.
| Class | CSS output | Description |
|---|---|---|
| .grow | flex-grow: 1 | Item grows to fill all available space. Shares evenly with other .grow items. |
| .grow-0 | flex-grow: 0 | Item does not grow beyond its natural or basis size. |
<!-- Middle item grows to fill all remaining space -->
<div class="flex gap-3">
<div class="grow-0">Fixed</div>
<div class="grow">Grows to fill space</div>
<div class="grow-0">Fixed</div>
</div>
<!-- All three items grow equally -->
<div class="flex gap-3">
<div class="grow">Equal</div>
<div class="grow">Equal</div>
<div class="grow">Equal</div>
</div>grow-0 / grow / grow-0
grow grow grow — equal distribution
Flex Shrink
ItemControls how much a flex item shrinks when the container doesn't have enough space to fit all items at their ideal size.
| Class | CSS output | Description |
|---|---|---|
| .shrink | flex-shrink: 1 | Item shrinks proportionally when container is too narrow (default). |
| .shrink-0 | flex-shrink: 0 | Item never shrinks — preserves its full width even when space is tight. |
<!-- Logo never shrinks; nav items share remaining space -->
<header class="flex items-center gap-4">
<img class="shrink-0 w-32" src="logo.svg" />
<nav class="flex gap-4 shrink">...</nav>
<button class="shrink-0">CTA</button>
</header>shrink-0 item preserves full width; shrink item compresses
Flex Basis
ItemSets the initial main size of a flex item before free space is distributed. Acts like width in row direction and height in column direction.
| Class | Value | Class | Value |
|---|---|---|---|
| .basis-auto | auto | .basis-1/2 | 50% |
| .basis-full | 100% | .basis-1/3 | 33.33% |
| .basis-0 | 0px | .basis-2/3 | 66.67% |
| .basis-1/4 | 25% | .basis-3/4 | 75% |
| .basis-1/5 | 20% | .basis-4/5 | 80% |
| .basis-1/6 | 16.67% | .basis-5/6 | 83.33% |
| .basis-1/12 | 8.33% | .basis-16 – .basis-96 | 4rem – 24rem |
<!-- Sidebar 1/4 + Main 3/4 layout -->
<div class="flex flex-wrap gap-4">
<aside class="basis-1/4">Sidebar</aside>
<main class="basis-3/4">Content</main>
</div>
<!-- Three equal columns -->
<div class="flex flex-wrap gap-4">
<div class="basis-1/3">Col 1</div>
<div class="basis-1/3">Col 2</div>
<div class="basis-1/3">Col 3</div>
</div>
<!-- Fixed sidebar + growing content -->
<div class="flex gap-4">
<nav class="basis-64 shrink-0">Nav (16rem)</nav>
<div class="grow">Main content</div>
</div>basis-1/3 × 3
basis-1/4 sidebar + basis-3/4 main
Flex Shorthand
ItemCombines flex-grow, flex-shrink, and flex-basis into a single class. These four cover the vast majority of real-world use cases.
| Class | CSS output | Behaviour |
|---|---|---|
| .flex-1 | flex: 1 1 0% | Grows, shrinks, starts from zero basis. The everyday workhorse for equal-width items. |
| .flex-auto | flex: 1 1 auto | Grows and shrinks from the item's natural size. Good for nav links that share leftover space. |
| .flex-initial | flex: 0 1 auto | Won't grow, but will shrink if needed. The browser default behaviour. |
| .flex-none | flex: none | Completely rigid — won't grow or shrink. Use for fixed-size elements. |
<!-- Three equal-width columns from zero basis -->
<div class="flex gap-4">
<div class="flex-1">Column</div>
<div class="flex-1">Column</div>
<div class="flex-1">Column</div>
</div>
<!-- Fixed avatar + growing text -->
<div class="flex items-center gap-3">
<img class="flex-none w-10 h-10 rounded-full" src="..." />
<div class="flex-1 min-w-0">
<p class="truncate">Username</p>
</div>
</div>
<!-- Nav: auto items share leftover space from natural size -->
<nav class="flex gap-2">
<a class="flex-auto text-center">Home</a>
<a class="flex-auto text-center">About</a>
<a class="flex-auto text-center">Contact</a>
</nav>flex-1 — equal columns from zero
flex-none + flex-1 + flex-none
Justification (Main Axis)
Justify Content
Container ResponsiveAligns flex items along the main axis (horizontal in flex-row, vertical in flex-col). Controls how leftover space is distributed.
| Class | CSS output | Description |
|---|---|---|
| .justify-start | justify-content: flex-start | Pack items toward the start of the main axis (default) |
| .justify-end | justify-content: flex-end | Pack items toward the end of the main axis |
| .justify-center | justify-content: center | Center items along the main axis |
| .justify-between | justify-content: space-between | First item at start, last at end, equal space between |
| .justify-around | justify-content: space-around | Equal space around each item (half-size at edges) |
| .justify-evenly | justify-content: space-evenly | Equal space between and around every item |
| .justify-stretch | justify-content: stretch | Items stretch to fill available space |
| .justify-normal | justify-content: normal | Browser default packing |
<div class="flex justify-start gap-2">...</div>
<div class="flex justify-center gap-2">...</div>
<div class="flex justify-end gap-2">...</div>
<div class="flex justify-between">...</div>
<div class="flex justify-around">...</div>
<div class="flex justify-evenly">...</div>
<!-- Responsive -->
<div class="flex justify-center lg:justify-between">...</div>justify-start
justify-center
justify-end
justify-between
justify-around
justify-evenly
Justify Items
Container ResponsiveSets the default justify-self for all flex items in the container. Affects inline-axis alignment of items within their grid/flex area.
| Class | CSS output |
|---|---|
| .justify-items-start | justify-items: start |
| .justify-items-end | justify-items: end |
| .justify-items-center | justify-items: center |
| .justify-items-stretch | justify-items: stretch |
<div class="flex justify-items-center">
<div>Item 1</div>
<div>Item 2</div>
</div>Justify Self
Item ResponsiveOverrides the container's justify-items for a single flex item.
| Class | CSS output |
|---|---|
| .justify-self-auto | justify-self: auto |
| .justify-self-start | justify-self: start |
| .justify-self-end | justify-self: end |
| .justify-self-center | justify-self: center |
| .justify-self-stretch | justify-self: stretch |
<div class="flex">
<div>Default</div>
<div class="justify-self-center">Centered</div>
<div class="justify-self-end">End</div>
</div>Alignment (Cross Axis)
Align Content
Container ResponsiveAligns flex lines along the cross axis when there are multiple lines (i.e. when flex-wrap is enabled and items wrap). Has no effect on single-line containers.
| Class | CSS output | Description |
|---|---|---|
| .content-normal | align-content: normal | Default packing |
| .content-start | align-content: flex-start | Lines packed to the start of cross axis |
| .content-end | align-content: flex-end | Lines packed to the end |
| .content-center | align-content: center | Lines centered on cross axis |
| .content-between | align-content: space-between | First line at start, last at end, equal space between |
| .content-around | align-content: space-around | Equal space around each line |
| .content-evenly | align-content: space-evenly | Equal space between and around every line |
| .content-stretch | align-content: stretch | Lines stretch to fill container height |
| .content-baseline | align-content: baseline | Lines aligned by their text baseline |
<!-- Must have flex-wrap + fixed height to see effect -->
<div class="flex flex-wrap content-start gap-2" style="height: 180px">
<div>1</div><div>2</div><div>3</div><div>4</div>
</div>
<div class="flex flex-wrap content-between gap-2" style="height: 180px">...</div>
<div class="flex flex-wrap content-center gap-2" style="height: 180px">...</div>content-start
content-center
content-between
content-end
content-around
content-stretch
Align Items
Container ResponsiveAligns all flex items along the cross axis within a single flex line. This is one of the most frequently used flexbox properties.
| Class | CSS output | Description |
|---|---|---|
| .items-start | align-items: flex-start | Items align to the start of the cross axis |
| .items-end | align-items: flex-end | Items align to the end of the cross axis |
| .items-center | align-items: center | Items center on the cross axis |
| .items-stretch | align-items: stretch | Items stretch to fill the cross-axis size of the container (default) |
| .items-baseline | align-items: baseline | Items align by their text baselines |
<!-- Vertically center items -->
<div class="flex items-center gap-4 h-24">
<div>Short</div>
<div class="h-16">Tall</div>
<div class="h-8">Medium</div>
</div>
<!-- Baseline alignment for mixed font sizes -->
<div class="flex items-baseline gap-3">
<span class="text-3xl font-bold">Big</span>
<span class="text-sm">small text aligned by baseline</span>
</div>
<!-- Responsive -->
<div class="flex items-start md:items-center">...</div>items-start
items-center
items-end
items-stretch
items-baseline
Align Self
Item ResponsiveOverrides the container's align-items for a single flex item on the cross axis.
| Class | CSS output |
|---|---|
| .self-auto | align-self: auto |
| .self-start | align-self: flex-start |
| .self-end | align-self: flex-end |
| .self-center | align-self: center |
| .self-stretch | align-self: stretch |
| .self-baseline | align-self: baseline |
<!-- All items start, but middle one centers itself -->
<div class="flex items-start gap-4 h-32">
<div>Top</div>
<div class="self-center">Middle</div>
<div class="self-end">Bottom</div>
<div class="self-stretch">Full height</div>
</div>Place Shorthands
Place Content
Container ResponsiveShorthand that sets both align-content and justify-content in one property. Useful for 2D centering of wrapped items.
| Class | CSS output |
|---|---|
| .place-content-center | place-content: center |
| .place-content-start | place-content: start |
| .place-content-end | place-content: end |
| .place-content-between | place-content: space-between |
| .place-content-around | place-content: space-around |
| .place-content-evenly | place-content: space-evenly |
| .place-content-stretch | place-content: stretch |
| .place-content-baseline | place-content: baseline |
<!-- Center all wrapped content both axes -->
<div class="flex flex-wrap place-content-center gap-3" style="height:200px">
<div>A</div><div>B</div><div>C</div>
<div>D</div><div>E</div>
</div>Place Items
Container ResponsiveShorthand for align-items + justify-items.
| Class | CSS output |
|---|---|
| .place-items-start | place-items: start |
| .place-items-end | place-items: end |
| .place-items-center | place-items: center |
| .place-items-stretch | place-items: stretch |
| .place-items-baseline | place-items: baseline |
<div class="flex place-items-center h-24">
<div>Centered both ways</div>
</div>Place Self
Item ResponsiveShorthand for align-self + justify-self on a single flex item.
| Class | CSS output |
|---|---|
| .place-self-auto | place-self: auto |
| .place-self-start | place-self: start |
| .place-self-end | place-self: end |
| .place-self-center | place-self: center |
| .place-self-stretch | place-self: stretch |
<div class="flex h-32">
<div class="place-self-start">Top-left</div>
<div class="place-self-center">Center</div>
<div class="place-self-end">Bottom-right</div>
</div>Order & Gap
Order
ItemControls the visual order of flex items without changing the DOM order. Useful for responsive reordering and screen-reader-friendly layouts.
| Class | CSS output | Use case |
|---|---|---|
| .order-first | order: -9999 | Visually first regardless of DOM position |
| .order-last | order: 9999 | Visually last regardless of DOM position |
| .order-none | order: 0 | Reset to natural order |
| .order-1 – .order-12 | order: 1–12 | Numeric ordering for up to 12 items |
<!-- DOM order: A B C D — Visual order: C A D B -->
<div class="flex gap-3">
<div class="order-2">A (DOM 1st)</div>
<div class="order-4">B (DOM 2nd)</div>
<div class="order-1">C (DOM 3rd)</div>
<div class="order-3">D (DOM 4th)</div>
</div>
<!-- Move sidebar before main on mobile -->
<div class="flex flex-col md:flex-row gap-4">
<main class="order-2 md:order-1">Content (DOM first)</main>
<aside class="order-1 md:order-2">Sidebar (DOM second, visually first on mobile)</aside>
</div>
<!-- Always first, regardless of position in DOM -->
<div class="order-first">Pinned to front</div>DOM: A B C D — Visual: C A D B
↑ Visual rendering reorders items without touching the DOM. Screen readers see A B C D.
Gap
Container From @mastors/coreGap utilities are provided by @mastors/core's spacing module and work for both flex and grid containers. They are available whenever @mastors/core is loaded. Use gap-{key}, gap-x-{key}, or gap-y-{key} where key is any spacing token.
| Class | CSS output | Value |
|---|---|---|
| .gap-0 | gap: 0 | No gap |
| .gap-1 | gap: 0.25rem | 4px |
| .gap-2 | gap: 0.5rem | 8px |
| .gap-3 | gap: 0.75rem | 12px |
| .gap-4 | gap: 1rem | 16px |
| .gap-6 | gap: 1.5rem | 24px |
| .gap-8 | gap: 2rem | 32px |
| .gap-x-{key} | column-gap: … | Horizontal gap only |
| .gap-y-{key} | row-gap: … | Vertical gap only |
<!-- Uniform gap -->
<div class="flex flex-wrap gap-4">
<div>Item</div><div>Item</div><div>Item</div>
</div>
<!-- Different column and row gaps -->
<div class="flex flex-wrap gap-x-6 gap-y-2">
<div>Item</div><div>Item</div><div>Item</div>
</div>gap-2
gap-6
gap-x-8 gap-y-2
Responsive
Breakpoint Variants
EngineAll utility modules marked Responsive generate breakpoint-prefixed variants using the core responsive engine. The pattern is {breakpoint}:{utility-class}. Breakpoints are mobile-first: a prefix means "apply at this breakpoint and above".
| Prefix | Min-width | Target |
|---|---|---|
| (none) | 0px | All viewports — base styles |
| sm: | 640px | Large phones and up |
| md: | 768px | Tablets and up |
| lg: | 1024px | Laptops and up |
| xl: | 1280px | Desktops and up |
| 2xl: | 1536px | Wide screens and up |
Responsive utilities available in @mastors/flexer:
<!-- Classic two-pane layout: stacked on mobile, side-by-side on md+ -->
<div class="flex flex-col md:flex-row gap-6">
<aside class="md:w-64 shrink-0">Sidebar</aside>
<main class="flex-1 min-w-0">Content</main>
</div>
<!-- Center on mobile, space-between on lg+ -->
<nav class="flex justify-center lg:justify-between items-center">
<div>Logo</div>
<ul class="hidden lg:flex gap-8">...</ul>
<button>CTA</button>
</nav>
<!-- Wrap on small, single row on xl+ -->
<div class="flex flex-wrap xl:flex-nowrap gap-4">
<div class="basis-full sm:basis-1/2 xl:flex-1">Card</div>
<div class="basis-full sm:basis-1/2 xl:flex-1">Card</div>
<div class="basis-full sm:basis-1/2 xl:flex-1">Card</div>
<div class="basis-full sm:basis-1/2 xl:flex-1">Card</div>
</div>
<!-- Reorder items responsively -->
<div class="flex flex-col md:flex-row gap-4">
<main class="order-2 md:order-1">Main (DOM 1st)</main>
<aside class="order-1 md:order-2">Sidebar (DOM 2nd, first on mobile)</aside>
</div>md (768px+).
Sass API — Mixins
flex-container()
MixinConfigure a complete flex container in a single @include. Eliminates the need to write display, flex-direction, flex-wrap, justify-content, align-items, and gap as separate declarations.
| Parameter | Type | Default | Description |
|---|---|---|---|
| $direction | String | row | Sets flex-direction |
| $wrap | String | nowrap | Sets flex-wrap |
| $justify | String | flex-start | Sets justify-content |
| $align | String | stretch | Sets align-items |
| $gap | CSS value | null | null | Sets gap (omitted if null) |
| $inline | Boolean | false | Use inline-flex instead of flex |
@use "@mastors/flexer/scss/mixins/flex-container" as *;
// Basic horizontal centered container
.hero {
@include flex-container($justify: center, $align: center);
}
// Card grid — wrapping row with gap
.card-grid {
@include flex-container($wrap: wrap, $gap: 1.5rem);
}
// Vertical nav sidebar
.sidebar-nav {
@include flex-container($direction: column, $align: flex-start, $gap: .5rem);
}
// Inline badge container
.chip-group {
@include flex-container($align: center, $gap: .5rem, $inline: true);
}
// Full toolbar: space-between with centered cross axis
.toolbar {
@include flex-container($justify: space-between, $align: center, $gap: 1rem);
padding: .75rem 1.25rem;
background: var(--mastors-surface);
}The mixin compiles to:
/* @include flex-container($wrap: wrap, $justify: space-between, $gap: 1rem) */
.example {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: stretch;
gap: 1rem;
}flex-item()
MixinConfigure a flex child item in one include. Sets flex, align-self, and order together.
| Parameter | Type | Default | Description |
|---|---|---|---|
| $grow | Number | 0 | flex-grow value |
| $shrink | Number | 1 | flex-shrink value |
| $basis | CSS value | auto | flex-basis value |
| $align | String | auto | align-self (omitted when auto) |
| $order | Number | null | null | order (omitted when null) |
@use "@mastors/flexer/scss/mixins/flex-item" as *;
// Fluid main content that grows from zero
.main-content {
@include flex-item($grow: 1, $basis: 0%);
}
// Fixed-width sidebar — never grows or shrinks
.sidebar {
@include flex-item($grow: 0, $shrink: 0, $basis: 280px);
}
// Card that starts at 300px but can shrink, centers itself
.card {
@include flex-item($grow: 1, $basis: 300px, $align: center);
}
// Item with explicit visual order
.featured {
@include flex-item($grow: 2, $order: 1);
}The mixin compiles to:
/* @include flex-item($grow: 1, $basis: 0%, $align: center) */
.main-content {
flex: 1 1 0%;
align-self: center;
}flex-center()
MixinThe single most common flex pattern — centering children on both axes — in one line. Comes in three variants: both axes, horizontal only (X), and vertical only (Y).
| Mixin | Compiles to | Use case |
|---|---|---|
| flex-center($inline?) | display:flex; align-items:center; justify-content:center | Both axes — icon buttons, hero sections, modal overlays |
| flex-center-x($inline?) | display:flex; justify-content:center | Main axis only — center a row of items horizontally |
| flex-center-y($inline?) | display:flex; align-items:center | Cross axis only — vertically center inline text + icon |
@use "@mastors/flexer/scss/mixins/flex-center" as *;
// Perfect centering — modal overlay, hero, spinner wrapper
.overlay {
@include flex-center;
position: fixed;
inset: 0;
background: rgba(0,0,0,.5);
}
// Center content area horizontally, not vertically
.page-header {
@include flex-center-x;
padding: 2rem 1rem;
}
// Icon + label inline — vertically center only
.btn {
@include flex-center-y($inline: true);
gap: .5rem;
padding: .5rem 1rem;
border-radius: .375rem;
}
// Inline icon badge
.badge {
@include flex-center($inline: true);
gap: .35rem;
padding: .2rem .5rem;
border-radius: 9999px;
}flex-center — both axes
flex-center-x — horizontal
flex-center-y — vertical
Generator
generate-flex-utilities()
GeneratorEmit a selective subset of flex utilities from a single config map. Use this when you want the utility pattern but not the full set — for example in a design system where you output only what each package needs.
| Config key | Type | Utilities emitted when true |
|---|---|---|
| direction | boolean | flex-row, flex-col, flex-row-reverse, flex-col-reverse |
| wrap | boolean | flex-wrap, flex-nowrap, flex-wrap-reverse |
| justify | boolean | justify-start, justify-center, justify-between, etc. |
| align | boolean | items-start, items-center, items-end, items-stretch, items-baseline |
| grow | boolean | grow, grow-0 |
| shrink | boolean | shrink, shrink-0 |
| order | boolean | order-first, order-last, order-none |
| responsive | boolean | Adds breakpoint-prefixed variants to all generated utilities |
@use "@mastors/flexer/scss/generators/flex-generator" as gen;
// Emit only direction + justify + align with responsive variants
// Useful for a component library that just needs layout primitives
@include gen.generate-flex-utilities((
direction: true,
justify: true,
align: true,
responsive: true,
));
// Emit everything including responsive variants
@include gen.generate-flex-utilities((
direction: true,
wrap: true,
justify: true,
align: true,
grow: true,
shrink: true,
order: true,
responsive: true,
));
// Emit only grow/shrink — no responsive variants needed
@include gen.generate-flex-utilities((
grow: true,
shrink: true,
));generate-flex-utilities() inside a design system or component package that extends Mastors, omit responsive: true unless you actually need breakpoint variants — each responsive utility emits one class per breakpoint × per value, which can add up.
Common Patterns
Real-world compositions using @mastors/flexer classes and mixins together.
Responsive Navbar
<header class="flex items-center justify-between gap-4 px-6 py-3">
<div class="flex items-center gap-3 shrink-0">
<img class="w-8 h-8" src="logo.svg" />
<span class="font-bold">Brand</span>
</div>
<nav class="hidden md:flex items-center gap-8">
<a href="#">Home</a>
<a href="#">Docs</a>
<a href="#">Blog</a>
</nav>
<div class="flex items-center gap-3 shrink-0">
<button class="hidden md:inline-flex items-center gap-2">Sign in</button>
<button class="md:hidden"><i class="fa-solid fa-bars"></i></button>
</div>
</header>Responsive Card Grid
<div class="flex flex-wrap gap-4">
<!-- Each card: full width on xs, half on sm, third on lg -->
<article class="basis-full sm:basis-[calc(50%-0.5rem)] lg:basis-[calc(33.333%-1rem)] flex flex-col gap-3 p-5 border rounded-xl">
<img class="w-full rounded-lg aspect-video object-cover" />
<div class="flex-1 flex flex-col gap-2">
<h3 class="font-semibold">Card title</h3>
<p class="text-sm text-muted flex-1">Description</p>
</div>
<div class="flex items-center justify-between">
<span class="text-xs text-muted">Jan 2025</span>
<button class="inline-flex items-center gap-1.5 text-sm">Read <i class="fa-solid fa-arrow-right"></i></button>
</div>
</article>
</div>Card title
Short description text that fills the card.
Card title
Another card with more description text here.
Card title
Third card example in the flex grid layout.
Media Object (Avatar + Content)
<div class="flex items-start gap-4">
<img class="shrink-0 w-12 h-12 rounded-full object-cover" src="avatar.jpg" />
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between gap-2">
<p class="font-semibold truncate">Jane Doe</p>
<time class="shrink-0 text-xs text-muted">2h ago</time>
</div>
<p class="text-sm text-muted mt-1">This is a reply or comment body...</p>
<div class="flex items-center gap-4 mt-2">
<button class="inline-flex items-center gap-1 text-xs">
<i class="fa-regular fa-heart"></i> 12
</button>
<button class="inline-flex items-center gap-1 text-xs">
<i class="fa-regular fa-comment"></i> Reply
</button>
</div>
</div>
</div>Jane Doe
This is a reply or comment body with some text that might be longer.