0
0
Tailwindmarkup~10 mins

Flex basis and sizing in Tailwind - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Flex basis and sizing
[Parse Tailwind classes] -> [Identify flex container] -> [Apply flex-basis from class] -> [Calculate item size] -> [Layout flex items] -> [Paint items] -> [Composite]
The browser reads Tailwind classes, applies flex-basis sizing to flex items, calculates their size based on flex rules, then lays out and paints them on screen.
Render Steps - 4 Steps
Code Added:<div class="flex"> container
Before
[ ]
(empty container, no children)
After
[__________________________]
(empty flex container, horizontal line)
Adding the flex container sets display:flex, creating a horizontal layout context.
🔧 Browser Action:Creates flex formatting context
Code Sample
A flex container with three boxes sized differently using flex-basis and flex-grow/shrink from Tailwind classes.
Tailwind
<div class="flex">
  <div class="flex-none w-24 bg-blue-500">Box 1</div>
  <div class="flex-auto bg-green-500">Box 2</div>
  <div class="flex-initial w-32 bg-red-500">Box 3</div>
</div>
Tailwind
/* Tailwind classes translate to: */
.flex { display: flex; }
.flex-none { flex: none; }
.flex-auto { flex: 1 1 auto; }
.flex-initial { flex: 0 1 auto; }
.w-24 { width: 6rem; }
.w-32 { width: 8rem; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-green-500 { background-color: #22c55e; }
.bg-red-500 { background-color: #ef4444; }
Render Quiz - 3 Questions
Test your understanding
After step 3, how does Box 2 behave visually inside the flex container?
AIt grows to fill leftover space after Box 1
BIt stays fixed size and does not grow
CIt shrinks smaller than its content
DIt disappears from the layout
Common Confusions - 3 Topics
Why does a flex-none item not grow even if there is space?
Because flex-none sets flex-grow to 0, the item keeps its fixed size and does not expand to fill space (see step 2).
💡 flex-grow:0 means no growing; item size stays fixed.
Why can flex-initial items shrink but not grow?
flex-initial sets flex-grow to 0 and flex-shrink to 1, so the item keeps its base size but can shrink if container is too small (see step 4).
💡 flex-shrink:1 allows shrinking; flex-grow:0 prevents growing.
What happens if no width is set on flex-auto item?
The flex-auto item uses flex-basis:auto, so it sizes based on content but can grow to fill leftover space (see step 3).
💡 flex-auto grows to fill space, width optional.
Property Reference
PropertyTailwind ClassDefault ValueVisual EffectCommon Use
flex-basisw-24, w-32, etc.autoSets initial size of flex itemControl fixed or minimum size
flex-growflex-auto (grow=1), flex-none (grow=0)0Allows item to grow to fill spaceFlexible layouts
flex-shrinkflex-initial (shrink=1), flex-none (shrink=0)1Allows item to shrink if neededPrevent overflow or keep size
flexflex-none, flex-auto, flex-initialflex: 0 1 autoShorthand for grow, shrink, basisQuick flex sizing
Concept Snapshot
flex-basis sets the starting size of a flex item. flex-grow controls if the item can expand to fill space. flex-shrink controls if the item can shrink when needed. Tailwind classes like flex-none, flex-auto, flex-initial combine these. Width classes (w-24, w-32) set fixed sizes used as flex-basis. Together they control how flex items size and fill the container.