Tutorials Tailwind CSS Flex Items
Ch 12 / 45
Chapter 12 Intermediate 8 min read Tailwind CSS

Flex Items in Tailwind CSS

In the last chapter you controlled the flex container — direction, wrapping, and alignment. This chapter flips the focus onto the children themselves: how much they grow, how much they shrink, what size they start at, what order they appear in, and how to override one item's alignment without touching the rest. These are the utilities that turn a basic flex row into a polished, responsive layout.

Advertisement
Google Ad Placeholder · 728×90 Leaderboard
What you'll learn
The difference between flex-grow and flex-shrink, and how they resolve space conflicts
Tailwind's flex shorthand — flex-1, flex-auto, flex-initial, flex-none
Setting a flex item's starting size with flex-basis
Reordering items visually with order, without touching the HTML
Overriding one item's cross-axis alignment with align-self
Real patterns — fixed sidebars, fill-remaining-space content, sticky action bars

What are Flex Items in Tailwind CSS?

Every direct child of a flex container is a flex item, and every flex item has three independent dimensions that decide its final size: grow (how eagerly it soaks up extra space), shrink (how eagerly it gives up space when the container is too small), and basis (its starting size before growing or shrinking happens).

Rather than setting all three separately every time, Tailwind ships four shorthand classes that cover the vast majority of real layouts in one word.

flex-1
flex: 1 1 0% — grows and shrinks freely, ignoring its content size. The go-to class for "fill whatever space is left".
flex-auto
flex: 1 1 auto — grows and shrinks, but starts from its own content size instead of zero.
flex-initial
flex: 0 1 auto — Tailwind's default. Can shrink if needed, but never grows beyond its content size.
flex-none
flex: none — completely rigid. Never grows, never shrinks, stays exactly its set size.
Tip Reach for flex-1 first for "fill the remaining space" columns, and flex-none (usually paired with a fixed width like w-64) for elements — sidebars, avatars, icons — that should never change size no matter what.

Flex Grow & Flex Shrink

For finer control than the shorthand classes give you, Tailwind exposes grow and shrink independently — set one without touching the other.

Grow & shrink classes — a quick reference
grow
flex-grow: 1 — the item expands to consume any leftover space in the container.
grow-0
Default. flex-grow: 0 — the item never grows past its natural or basis size, even if space is left over.
shrink
Default. flex-shrink: 1 — the item shrinks below its basis size when the container is too small to fit everyone.
shrink-0
flex-shrink: 0 — the item refuses to shrink, even if it causes overflow. Essential for icons, avatars, and fixed-width sidebars.
One item grows, one item stays fixed
<!-- Fixed sidebar (never shrinks) + content that fills the rest -->
<div class="flex gap-4 h-40">
  <div class="shrink-0 w-32 bg-purple-500 rounded-lg">Sidebar</div>
  <div class="flex-1 bg-cyan-500 rounded-lg">Main content — fills whatever space is left</div>
</div>

<!-- Two equal-width columns -->
<div class="flex gap-4">
  <div class="flex-1 bg-orange-500 rounded-lg p-4">Column A</div>
  <div class="flex-1 bg-green-500 rounded-lg p-4">Column B</div>
</div>

Flex Basis — Starting Size

basis-* sets an item's size before any growing or shrinking is applied. Think of it as a smarter width that flexbox is allowed to adjust from — it uses the same spacing scale as w-*, plus fraction values for column-style splits.

Class CSS Equivalent Common use
basis-0 flex-basis: 0px Pair with grow for pure ratio-based sizing
basis-auto flex-basis: auto Default — size from content or width
basis-1/2 flex-basis: 50% Two equal-ish columns
basis-1/3 flex-basis: 33.333% Three-column starting size
basis-64 flex-basis: 16rem Fixed-width starting size (256px)
basis-full flex-basis: 100% Force an item onto its own line when wrapped
Note When both are set, basis-* wins over w-* for a flex item's starting size along the main axis — flexbox always computes layout from flex-basis first, then applies grow/shrink on top of it.

Order & Align-Self — Per-Item Overrides

These two utilities target a single flex item rather than the whole container — order changes where it visually appears, and self-* overrides its cross-axis alignment.

Order classes — visual position, not DOM position
order-1 … order-12
Numeric ordering — lower numbers render first. Items without an order class default to order: 0.
order-first
Shorthand for order: -9999 — always renders before every sibling.
order-last
Shorthand for order: 9999 — always renders after every sibling.
order-none
Resets to the default source order — order: 0.
Align-self classes — override align-items for one item
self-auto
Default. Inherits whatever align-items is set on the parent container.
self-center
Centres just this item on the cross axis, regardless of how its siblings are aligned.
self-start / self-end
Pins this single item to the start or end of the cross axis, breaking away from the group.
self-stretch
Stretches just this item to fill the container's cross axis, even if others aren't stretched.
Reordering & overriding a single item
<!-- Written 1, 2, 3 in HTML — rendered visually as 3, 1, 2 -->
<div class="flex gap-4">
  <div class="order-2">Item 1</div>
  <div class="order-3">Item 2</div>
  <div class="order-1">Item 3</div>
</div>

<!-- Every card centred, except the featured one which stretches -->
<div class="flex items-center gap-4">
  <div class="p-4 bg-gray-100 rounded-lg">Card</div>
  <div class="self-stretch p-4 bg-cyan-500 text-white rounded-lg">Featured Card</div>
  <div class="p-4 bg-gray-100 rounded-lg">Card</div>
</div>

Live Examples — See Flex Items in Action

These boxes are rendered with real Tailwind utility classes right on this page.

shrink-0 w-32 sidebar + flex-1 content:

Live Preview
Sidebar
flex-1 fills the rest

order-1 / order-2 / order-3 — visual order overriding markup order:

Live Preview — written A, B, C in HTML
A (order-3)
B (order-1)
C (order-2)

self-end breaking one item away from items-center:

Live Preview
center
self-end
center

Common Real-World Use Cases

Flex item utilities are what turn a basic row into a layout that behaves exactly the way you want as content and screen size change.

Sidebar That Never Shrinks
shrink-0 w-64 on the sidebar keeps it a fixed width no matter how little room is left.
Content That Fills the Rest
flex-1 on the main content area automatically absorbs whatever space the fixed elements don't use.
Reordering for Mobile-First
order-2 md:order-1 lets you write markup in a logical order and visually rearrange it per breakpoint.
Sticky Action Bar
An empty flex-1 spacer between left and right groups pushes buttons apart without needing justify-between.
Equal-Width Columns
Adding flex-1 to every child in a row forces them all to share the available space equally.
One Item Breaking Alignment
self-start or self-end on a single card lets it opt out of the row's shared alignment.

Quick Reference — Flex Item Classes

Class CSS Equivalent Description
flex-1 flex: 1 1 0% Grow and shrink freely, ignoring content size
flex-auto flex: 1 1 auto Grow and shrink from its own content size
flex-initial flex: 0 1 auto Default — can shrink, never grows
flex-none flex: none Never grows or shrinks — fully rigid
grow flex-grow: 1 Expands to consume leftover space
grow-0 flex-grow: 0 Default — never grows past natural size
shrink flex-shrink: 1 Default — shrinks when space is tight
shrink-0 flex-shrink: 0 Refuses to shrink, even causing overflow
basis-1/2 flex-basis: 50% Starting size before grow/shrink applies
basis-auto flex-basis: auto Default — size based on content/width
order-1 order: 1 Visual position, independent of DOM order
order-first order: -9999 Always renders before all siblings
order-last order: 9999 Always renders after all siblings
self-center align-self: center Overrides align-items for one item
self-stretch align-self: stretch Stretches just this item on the cross axis
self-auto align-self: auto Default — inherits the container's align-items
Featured Course
Master Tailwind CSS with Real Projects(React Course)
Go from utility-class beginner to building production-grade UIs. Our structured course covers Tailwind v4, Vite integration, custom themes, component patterns, and 5 real projects including a full SaaS landing page and dashboard.
45 Chapters 10+ Hours of Content 5 Real Projects Certificate Included Live Mentoring
🎨
⭐ 4.9 · 1,200+ students
Tailwind CSS Flex Items Cheat Sheet
Download our free one-page cheat sheet covering every flex-grow, flex-shrink, flex-basis, order, and align-self utility class with CSS equivalents.
Flex Items Grow & Shrink Flex-Basis Order Align-Self Layout
Download Free Cheat Sheet
Chapter Summary
  • Every flex item has three independent sizing dimensions: grow, shrink, and basis.
  • Tailwind's shorthand — flex-1, flex-auto, flex-initial, flex-none — covers most real layouts in one class.
  • grow, shrink, and basis-* give finer, independent control when the shorthand isn't enough.
  • order changes only the visual position of an item — the DOM and accessibility order stay untouched.
  • align-self overrides align-items for a single item, without affecting its siblings.
  • Real patterns: fixed sidebars with shrink-0, fill-remaining-space content with flex-1, and responsive reordering with order-*.
  • Next chapter moves into CSS Grid — building two-dimensional layouts with grid-cols-* and grid-rows-*.

Quick Check — Questions & Answers

Test your understanding of this chapter. Click a question to reveal the answer.

flex-basis sets an item's starting size, before any flexing happens — it answers "how big should this be to begin with?" flex-grow then answers a completely different question: "if there's leftover space after every item has its basis size, how much of it should this item take?" An item can have a large basis and zero grow (fixed size), or a zero basis and grow of 1 (pure ratio-based sizing) — they work together, not against each other.
It comes down to their basis value. flex-1 is flex: 1 1 0% — the basis is 0, so the browser pretends the item starts at zero width and grows purely by its grow ratio relative to siblings. flex-auto is flex: 1 1 auto — the basis is auto, so the item starts at its natural content width and only then grows to fill remaining space, meaning items with more text start out bigger.
Give the sidebar shrink-0 plus a fixed width like w-64, and give the main content flex-1:

<div class="flex"><aside class="shrink-0 w-64">...</aside><main class="flex-1">...</main></div>

Without shrink-0, the sidebar would still shrink below 256px if the viewport got narrow enough to force it, since flex items shrink by default.
Only the visual rendering changes — the underlying DOM order is completely untouched.

This matters for accessibility: screen readers and keyboard tab order follow the DOM, not the CSS order value, so a sighted user and a keyboard/screen-reader user can experience a different sequence if you're not careful. Use order for cosmetic rearrangement, not as a substitute for writing your HTML in a sensible reading order to begin with.
Add an self-* class directly to that one item — it overrides whatever align-items is set on the parent, without touching any sibling.

Example: <div class="flex items-center"><div>Card</div><div class="self-end">This one aligns to the bottom</div></div> — every other child stays vertically centred, only the one with self-end breaks away.

MCQ Quiz — Test Yourself

Select the best answer for each question. Correct answers are revealed after you click.

Question 1 of 4
Which class makes an item grow to fill available space and ignores its own content size when calculating that growth?
Question 2 of 4
Which class prevents an item from shrinking below its size, even if the container is too small to fit everyone?
Question 3 of 4
Which class visually moves an item to the very end of a flex row, regardless of where it sits in the HTML?
Question 4 of 4
Which class overrides align-items for a single flex child, without affecting its siblings?

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel