Flexbox Demo
1. Row direction
Items sit next to each other from left to right.
A
B
C
.row-demo {
display: flex;
flex-direction: row;
}
2. Column direction
Items stack from top to bottom.
A
B
C
.column-demo {
display: flex;
flex-direction: column;
}
3. justify-content
This controls distribution along the main axis.
A
B
C
.justify-demo {
display: flex;
justify-content: space-between;
}
4. align-items
This controls alignment on the cross axis.
A
B
C
.align-demo {
display: flex;
align-items: center;
}
5. gap
Gap adds space between items without using margins on the children.
A
B
C
.gap-demo {
display: flex;
gap: 24px;
}
6. flex-wrap
Items can move onto a new line when there is not enough room.
Tag 1
Tag 2
Tag 3
Tag 4
Tag 5
Tag 6
.wrap-demo {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
7. flex-grow
One item can expand and take the remaining available space.
Logo
Search area grows
Button
.grow-demo {
display: flex;
gap: 12px;
}
.grow-item {
flex-grow: 1;
}
8. Figma-like header
This behaves like a horizontal Auto Layout frame in Figma.
Studio
.ui-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 24px;
}
9. Responsive flex layout
This row becomes a column on smaller screens.
Image
Content
Actions
.responsive-flex-demo {
display: flex;
gap: 16px;
}
.responsive-item {
flex: 1;
}
@media (max-width: 700px) {
.responsive-flex-demo {
flex-direction: column;
}
}
10. Playground
Try `display: flex`, `gap`, `justify-content`, and `align-items` here.
Card 1
Card 2
Card 3