Layout Snippets — Free HTML CSS JS Page Layout Components
58 layout components · Hero, Bento Grid, Split Hero, Masonry, Timeline, Image Comparison · Exports to React, Vue, Angular & Tailwind
What's included
Features
About this tool
Layout Snippets — Free Hero Sections, Bento Grids, Masonry, Timelines, Image Comparison & More
Layout components define the visual structure of a page — how content is arranged, how sections relate to each other, and how the design responds across screen sizes. Getting layout right is the difference between a page that communicates clearly and one that feels cluttered or broken on mobile. This collection covers 11 of the most commonly needed page sections and structural patterns.
Every snippet is plain HTML and CSS — most need zero JavaScript. Each demonstrates a real CSS technique that applies in any project.
Hero Section uses a radial-gradient glow effect centred on the page as a visual focal point. The headline uses clamp(28px, 5vw, 56px) for fluid type sizing that scales between a minimum and maximum without media queries. Two CTAs — a filled primary and an outlined secondary — cover the standard hero action pattern.
CSS Grid Cards layout uses grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)). This single rule creates a fully responsive grid: the browser calculates how many 220px minimum columns fit the container width and fills the remaining space with 1fr. On a wide desktop this produces 4–5 columns; on mobile, 1 column. No media queries, no JavaScript resize handler.
Bento Grid mimics the Apple-style mixed-size grid layout. Some cells use grid-column: span 2 to occupy double width. Others span two rows. The overall layout uses gap: 12px and a dark background. Hover states add an accent border glow to individual cells.
Split Hero uses display: grid; grid-template-columns: 1fr 1fr to place copy on the left and a terminal code panel on the right. The code panel uses a dark background with syntax-coloured text (CSS spans for keywords, strings, and comments) — no syntax highlighting library.
Vertical Timeline uses a ::before pseudo-element on the timeline container as the vertical line. The line uses a linear-gradient from accent to transparent so it fades out at the bottom. Each node has done (filled checkmark), active (pulsing accent), and pending (grey) states.
Image Comparison uses clip-path: inset(0 X% 0 0) on the "after" image, where X is the drag position as a percentage. Dragging the handle updates X via a mousemove handler that reads clientX relative to the container. Touch events use e.touches[0].clientX. The percentage is clamped between 2 and 98 to prevent the before/after images from fully disappearing.
Masonry Grid uses CSS columns: 3 and break-inside: avoid. Children fill top-to-bottom in columns and the browser handles variable height items automatically — no JavaScript height calculation needed. This is browser-native masonry layout.
Chat UI, Empty State, 404 Page, and Pricing Toggle complete the collection with the remaining essential layout patterns.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) is a fully intrinsic grid. auto-fill places as many columns as can fit in the container. minmax(220px, 1fr) means each column is at least 220px wide and can grow to fill the available space. When the container gets narrower than 440px (2 × 220px), the browser automatically reduces to a single column. When it is wide enough for 3 columns, it shows 3. The browser recalculates on every resize without JavaScript.
columns: 3 tells the browser to divide the container into 3 equal-width columns. Child elements flow into columns top-to-bottom, like a newspaper layout. break-inside: avoid prevents a single card from splitting across two columns. The browser handles variable-height items automatically — short items sit naturally next to tall items without gaps. For a 2-column layout: columns: 2. For responsive: columns: repeat(auto-fill, minmax(220px, 1fr)) also works with the CSS columns property.
The "after" image has clip-path: inset(0 X% 0 0) where X is the drag position as a percentage of the container width. mousemove computes X as (e.clientX - rect.left) / rect.width × 100, clamped between 2 and 98 so neither image fully disappears. The same calculation runs on touchmove using e.touches[0].clientX. setPos(x) applies the clip-path and positions the drag handle at the same percentage. dragging is a flag set in mousedown/touchstart and cleared in mouseup/touchend.
Yes. Every layout has a JSX export. In Next.js, use the Hero section and Split Hero as page section components in your app/page.tsx. The CSS Grid Cards layout works identically in JSX — apply the CSS as a className via CSS Modules or paste the styles into a Tailwind arbitrary value. For the Image Comparison, use useRef for the container element, useState for the position percentage, and attach event listeners in useEffect. The Masonry Grid is pure CSS — no JavaScript changes needed.