M
@mastors/flexer v1.2.7

@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.

19
Utility Modules
3
Sass Mixins
6
Breakpoints
100%
CSS Flexbox API
All utilities marked Responsive generate breakpoint-prefixed variants: 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/flexer

pnpm

pnpm add @mastors/flexer

yarn

yarn add @mastors/flexer

Import & 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 Responsive

Establishes a flex formatting context on the element. Use flex for block-level and inline-flex for inline-level containers.

ClassCSS outputWhen to use
.flexdisplay: flexBlock-level flex container — takes full width of parent
.inline-flexdisplay: inline-flexInline 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

Item 1
Item 2
Item 3

.inline-flex — hugs content

Inline flex badge

Direction & Wrapping

Flex Direction

Container Responsive

Controls the main axis — the direction items are placed in a flex container.

ClassCSS outputDescription
.flex-rowflex-direction: rowLeft to right (default). Main axis is horizontal.
.flex-row-reverseflex-direction: row-reverseRight to left. Items appear in reverse order horizontally.
.flex-colflex-direction: columnTop to bottom. Main axis is vertical.
.flex-col-reverseflex-direction: column-reverseBottom 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

1
2
3

flex-row-reverse

1
2
3

flex-col

1
2
3

flex-col-reverse

1
2
3

Flex Wrap

Container Responsive

Controls whether flex items wrap to the next line when they overflow the container's main axis.

ClassCSS outputDescription
.flex-wrapflex-wrap: wrapItems wrap to the next row/column when they overflow.
.flex-wrap-reverseflex-wrap: wrap-reverseItems wrap, but wrapped lines appear before the first line.
.flex-nowrapflex-wrap: nowrapNo 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

Alpha
Beta
Gamma
Delta
Epsilon
Zeta

flex-nowrap — all on one line

Alpha
Beta
Gamma
Delta
Epsilon

Flex Flow

Container Responsive

Shorthand that sets both flex-direction and flex-wrap in a single class.

ClassCSS output
.flex-flow-row-wrapflex-flow: row wrap
.flex-flow-row-nowrapflex-flow: row nowrap
.flex-flow-row-wrap-reverseflex-flow: row wrap-reverse
.flex-flow-col-wrapflex-flow: column wrap
.flex-flow-col-nowrapflex-flow: column nowrap
.flex-flow-col-wrap-reverseflex-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

Item

Controls how much a flex item grows to fill available free space in the container relative to its siblings.

ClassCSS outputDescription
.growflex-grow: 1Item grows to fill all available space. Shares evenly with other .grow items.
.grow-0flex-grow: 0Item 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

Fixed
Grows →
Fixed

grow grow grow — equal distribution

Equal
Equal
Equal

Flex Shrink

Item

Controls how much a flex item shrinks when the container doesn't have enough space to fit all items at their ideal size.

ClassCSS outputDescription
.shrinkflex-shrink: 1Item shrinks proportionally when container is too narrow (default).
.shrink-0flex-shrink: 0Item 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

shrink-0
shrink (compresses to fit)
shrink-0

Flex Basis

Item

Sets the initial main size of a flex item before free space is distributed. Acts like width in row direction and height in column direction.

ClassValueClassValue
.basis-autoauto.basis-1/250%
.basis-full100%.basis-1/333.33%
.basis-00px.basis-2/366.67%
.basis-1/425%.basis-3/475%
.basis-1/520%.basis-4/580%
.basis-1/616.67%.basis-5/683.33%
.basis-1/128.33%.basis-16 – .basis-964rem – 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

1/3
1/3
1/3

basis-1/4 sidebar + basis-3/4 main

Sidebar
Main content

Flex Shorthand

Item

Combines flex-grow, flex-shrink, and flex-basis into a single class. These four cover the vast majority of real-world use cases.

ClassCSS outputBehaviour
.flex-1flex: 1 1 0%Grows, shrinks, starts from zero basis. The everyday workhorse for equal-width items.
.flex-autoflex: 1 1 autoGrows and shrinks from the item's natural size. Good for nav links that share leftover space.
.flex-initialflex: 0 1 autoWon't grow, but will shrink if needed. The browser default behaviour.
.flex-noneflex: noneCompletely 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-1
flex-1
flex-1

flex-none + flex-1 + flex-none

none
grows
none

Justification (Main Axis)

Justify Content

Container Responsive

Aligns flex items along the main axis (horizontal in flex-row, vertical in flex-col). Controls how leftover space is distributed.

ClassCSS outputDescription
.justify-startjustify-content: flex-startPack items toward the start of the main axis (default)
.justify-endjustify-content: flex-endPack items toward the end of the main axis
.justify-centerjustify-content: centerCenter items along the main axis
.justify-betweenjustify-content: space-betweenFirst item at start, last at end, equal space between
.justify-aroundjustify-content: space-aroundEqual space around each item (half-size at edges)
.justify-evenlyjustify-content: space-evenlyEqual space between and around every item
.justify-stretchjustify-content: stretchItems stretch to fill available space
.justify-normaljustify-content: normalBrowser 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

A
B
C

justify-center

A
B
C

justify-end

A
B
C

justify-between

A
B
C

justify-around

A
B
C

justify-evenly

A
B
C

Justify Items

Container Responsive

Sets the default justify-self for all flex items in the container. Affects inline-axis alignment of items within their grid/flex area.

ClassCSS output
.justify-items-startjustify-items: start
.justify-items-endjustify-items: end
.justify-items-centerjustify-items: center
.justify-items-stretchjustify-items: stretch
<div class="flex justify-items-center">
  <div>Item 1</div>
  <div>Item 2</div>
</div>

Justify Self

Item Responsive

Overrides the container's justify-items for a single flex item.

ClassCSS output
.justify-self-autojustify-self: auto
.justify-self-startjustify-self: start
.justify-self-endjustify-self: end
.justify-self-centerjustify-self: center
.justify-self-stretchjustify-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 Responsive

Aligns 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.

ClassCSS outputDescription
.content-normalalign-content: normalDefault packing
.content-startalign-content: flex-startLines packed to the start of cross axis
.content-endalign-content: flex-endLines packed to the end
.content-centeralign-content: centerLines centered on cross axis
.content-betweenalign-content: space-betweenFirst line at start, last at end, equal space between
.content-aroundalign-content: space-aroundEqual space around each line
.content-evenlyalign-content: space-evenlyEqual space between and around every line
.content-stretchalign-content: stretchLines stretch to fill container height
.content-baselinealign-content: baselineLines 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

A
B
C
D

content-center

A
B
C
D

content-between

A
B
C
D

content-end

A
B
C
D

content-around

A
B
C
D

content-stretch

A
B
C
D

Align Items

Container Responsive

Aligns all flex items along the cross axis within a single flex line. This is one of the most frequently used flexbox properties.

ClassCSS outputDescription
.items-startalign-items: flex-startItems align to the start of the cross axis
.items-endalign-items: flex-endItems align to the end of the cross axis
.items-centeralign-items: centerItems center on the cross axis
.items-stretchalign-items: stretchItems stretch to fill the cross-axis size of the container (default)
.items-baselinealign-items: baselineItems 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

A
B
C

items-center

A
B
C

items-end

A
B
C

items-stretch

A
B
C

items-baseline

A
B

Align Self

Item Responsive

Overrides the container's align-items for a single flex item on the cross axis.

ClassCSS output
.self-autoalign-self: auto
.self-startalign-self: flex-start
.self-endalign-self: flex-end
.self-centeralign-self: center
.self-stretchalign-self: stretch
.self-baselinealign-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>
start
center
end
stretch

Place Shorthands

Place Content

Container Responsive

Shorthand that sets both align-content and justify-content in one property. Useful for 2D centering of wrapped items.

ClassCSS output
.place-content-centerplace-content: center
.place-content-startplace-content: start
.place-content-endplace-content: end
.place-content-betweenplace-content: space-between
.place-content-aroundplace-content: space-around
.place-content-evenlyplace-content: space-evenly
.place-content-stretchplace-content: stretch
.place-content-baselineplace-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 Responsive

Shorthand for align-items + justify-items.

ClassCSS output
.place-items-startplace-items: start
.place-items-endplace-items: end
.place-items-centerplace-items: center
.place-items-stretchplace-items: stretch
.place-items-baselineplace-items: baseline
<div class="flex place-items-center h-24">
  <div>Centered both ways</div>
</div>

Place Self

Item Responsive

Shorthand for align-self + justify-self on a single flex item.

ClassCSS output
.place-self-autoplace-self: auto
.place-self-startplace-self: start
.place-self-endplace-self: end
.place-self-centerplace-self: center
.place-self-stretchplace-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

Item

Controls the visual order of flex items without changing the DOM order. Useful for responsive reordering and screen-reader-friendly layouts.

ClassCSS outputUse case
.order-firstorder: -9999Visually first regardless of DOM position
.order-lastorder: 9999Visually last regardless of DOM position
.order-noneorder: 0Reset to natural order
.order-1 – .order-12order: 1–12Numeric 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

A
B
C
D

↑ Visual rendering reorders items without touching the DOM. Screen readers see A B C D.

Gap

Container From @mastors/core

Gap 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.

ClassCSS outputValue
.gap-0gap: 0No gap
.gap-1gap: 0.25rem4px
.gap-2gap: 0.5rem8px
.gap-3gap: 0.75rem12px
.gap-4gap: 1rem16px
.gap-6gap: 1.5rem24px
.gap-8gap: 2rem32px
.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

A
B
C
D

gap-6

A
B
C
D

gap-x-8 gap-y-2

A
B
C
D

Responsive

Breakpoint Variants

Engine

All 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".

PrefixMin-widthTarget
(none)0pxAll viewports — base styles
sm:640pxLarge phones and up
md:768pxTablets and up
lg:1024pxLaptops and up
xl:1280pxDesktops and up
2xl:1536pxWide screens and up

Responsive utilities available in @mastors/flexer:

flex / inline-flex flex-row / col / row-reverse / col-reverse flex-wrap / nowrap / wrap-reverse flex-flow-* justify-* justify-items-* justify-self-* content-* items-* self-* place-content-* place-items-* place-self-*
<!-- 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>
Resize this browser window to see responsive classes activate. The sidebar in the layout above stacks on mobile and moves beside the content at md (768px+).

Sass API — Mixins

flex-container()

Mixin

Configure 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.

ParameterTypeDefaultDescription
$directionStringrowSets flex-direction
$wrapStringnowrapSets flex-wrap
$justifyStringflex-startSets justify-content
$alignStringstretchSets align-items
$gapCSS value | nullnullSets gap (omitted if null)
$inlineBooleanfalseUse 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()

Mixin

Configure a flex child item in one include. Sets flex, align-self, and order together.

ParameterTypeDefaultDescription
$growNumber0flex-grow value
$shrinkNumber1flex-shrink value
$basisCSS valueautoflex-basis value
$alignStringautoalign-self (omitted when auto)
$orderNumber | nullnullorder (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()

Mixin

The 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).

MixinCompiles toUse case
flex-center($inline?)display:flex; align-items:center; justify-content:centerBoth axes — icon buttons, hero sections, modal overlays
flex-center-x($inline?)display:flex; justify-content:centerMain axis only — center a row of items horizontally
flex-center-y($inline?)display:flex; align-items:centerCross 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

Centered

flex-center-x — horizontal

Center H

flex-center-y — vertical

Center V

Generator

generate-flex-utilities()

Generator

Emit 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 keyTypeUtilities emitted when true
directionbooleanflex-row, flex-col, flex-row-reverse, flex-col-reverse
wrapbooleanflex-wrap, flex-nowrap, flex-wrap-reverse
justifybooleanjustify-start, justify-center, justify-between, etc.
alignbooleanitems-start, items-center, items-end, items-stretch, items-baseline
growbooleangrow, grow-0
shrinkbooleanshrink, shrink-0
orderbooleanorder-first, order-last, order-none
responsivebooleanAdds 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,
));
When using 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>
M
Brand

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.

Jan 2025Read →

Card title

Another card with more description text here.

Feb 2025Read →

Card title

Third card example in the flex grid layout.

Mar 2025Read →

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>
J

Jane Doe

This is a reply or comment body with some text that might be longer.