If you've ever opened a CRM, an analytics tool or an admin panel and wondered how they fit so much information on one screen without it feeling messy, the answer is usually the F-shape layout.
In this post I'll break down how to build one from scratch with CSS Grid and Flexbox, using a responsive glassmorphic CRM dashboard as the project. No frameworks, no libraries, just HTML, CSS and a little vanilla JavaScript.
Prefer to watch? This article is the written companion to my full video tutorial, where I build the whole thing step by step:
What is an F-shape layout?
Eye tracking studies show people scan screens in an F pattern. They read across the top first, then do a second shorter sweep a little lower, and then scan down the left side.
A dashboard built around that behavior looks like this:
[sidebar] [ top bar ........................ ] first stroke
[sidebar] [ banner + stats ................. ] second stroke
[sidebar] [ card ] [ card ] [ card ] [ card ] vertical scan
[sidebar] [ card ] [ card ] [ card ] [ card ]
Important things sit at the top and left, and everything else stacks in a predictable, scannable order. That's why you see this pattern in so many SaaS products.
The tools: Grid for structure, Flexbox for components
The rule I follow on almost every layout: use CSS Grid for the page skeleton, and Flexbox for alignment inside each component.
Grid is two dimensional, so it's perfect for the big structure (a sidebar column plus a content column, and rows of equal cards). Flexbox is one dimensional, so it's perfect for lining up a logo and a button, or stacking an avatar above a name.
Step 1: Set up CSS variables first
Before styling anything, define your design system once as custom properties:
:root {
--bg-canvas: #090a10;
--glass-card: rgba(22, 25, 36, 0.55);
--accent-orange: #ff7518;
--radius-lg: 24px;
--radius-full: 9999px;
--transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
Now every color, radius and transition lives in one place. Rebranding the entire dashboard means editing a few lines instead of hunting through hundreds.
Step 2: Reset and base styles
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
box-sizing: border-box makes padding and borders count inside an element's width, which makes Grid and Flexbox math far more predictable.
Step 3: The F-shape shell with CSS Grid
This is the most important decision in the whole layout:
.dashboard-layout {
display: grid;
grid-template-columns: 78px 1fr;
width: 100vw;
height: 100vh;
}
The first column is a fixed 78px sidebar. 1fr means "take whatever space is left" for the main content. Two lines of CSS give you the entire page skeleton.
Step 4: The sidebar with Flexbox
Inside that 78px column, Flexbox stacks the logo and navigation icons vertically and centers them:
.sidebar {
display: flex;
flex-direction: column;
align-items: center;
padding: 22px 0;
backdrop-filter: blur(24px) saturate(180%);
}
.sidebar-menu {
display: flex;
flex-direction: column;
gap: 14px;
}
Notice gap. It replaces the old habit of adding margins to every child and then removing the last one.
Step 5: Glassmorphism
The frosted glass look comes from two things working together: a semi transparent background and backdrop-filter.
.crm-card {
background: rgba(22, 25, 36, 0.55);
backdrop-filter: blur(24px) saturate(180%);
border-radius: 24px;
box-shadow: 0 14px 34px -6px rgba(0, 0, 0, 0.65);
}
backdrop-filter blurs whatever is behind the element, not the element itself. That's why the transparent background matters: without it, there's nothing visible to blur.
Step 6: The card grid
Each section of cards is a four column grid:
.cards-row {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 16px;
}
Inside each card, Flexbox pins the footer to the bottom no matter how much content sits above it:
.crm-card {
display: flex;
flex-direction: column;
justify-content: space-between;
}
Step 7: The cutout corner trick (pure CSS)
Every card has a notch cut out of its top right corner. It's not an image or an SVG. It's a small box painted in the page background color, with two pseudo elements using oversized box shadows to fake the curved edges:
.cutout-wrapper {
position: absolute;
top: 0;
right: 0;
width: 58px;
height: 58px;
background-color: var(--bg-canvas);
border-bottom-left-radius: 24px;
}
.cutout-wrapper::before {
content: '';
position: absolute;
top: 0;
left: -20px;
width: 20px;
height: 20px;
border-top-right-radius: 20px;
box-shadow: 6px -6px 0 6px var(--bg-canvas);
}
The one catch is that the cutout color must match your page background exactly, since it works by painting over the card.
Step 8: Making it responsive
I build desktop first, then use media queries to adapt as the screen shrinks. The key is choosing breakpoints based on when the layout starts to feel cramped, not on specific device names.
@media (max-width: 1280px) {
.cards-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
.dashboard-layout {
display: flex;
flex-direction: column;
}
.sidebar {
flex-direction: row;
position: sticky;
top: 0;
}
.cards-row { grid-template-columns: 1fr; }
}
At tablet width the grid drops from four columns to two. On mobile, the whole page switches from a Grid with a side column into a Flexbox column, the sidebar becomes a sticky top bar, and the cards stack into a single column.
Step 9: A little JavaScript
The interactivity is small. Clicking a filter pill moves the active class to it:
document.querySelectorAll('.dashboard-section').forEach((section) => {
const pills = section.querySelectorAll('.filter-pill');
pills.forEach((pill) => {
pill.addEventListener('click', () => {
pills.forEach((p) => p.classList.remove('active'));
pill.classList.add('active');
});
});
});
Scoping the logic to each section means filtering the tasks never affects the leads.
Key takeaways
- Use Grid for the page structure and Flexbox inside components.
- Define colors, radii and transitions as CSS variables first.
-
Glassmorphism needs a transparent background plus
backdrop-filter. - Pick breakpoints based on content, not devices.
- Style the pattern once (
.crm-card) and reuse it with modifier classes (.card-featured).
Watch the full build
This post covers the main ideas, but the video walks through every component line by line, with each CSS rule explained as we write it:
Take Your CSS to the Next Level š
If you want to build clean, responsive layouts like a senior developer even faster, I packaged these architectural patterns into a practical resource:
š Grab the Guide: Build Any Responsive Layout with CSS Grid & Flexbox
It is designed to take you from layout confusion to confidently building any complex layout you see online!
Top comments (0)