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

Share & Support

What's included

Features

11 layout components covering full page sections and structural patterns
Hero: radial-gradient glow + clamp() fluid type + dual CTA pattern
CSS grid cards: repeat(auto-fill,minmax(220px,1fr)) — fully responsive with one CSS rule
Bento grid: grid-column/row span for mixed-size cells, hover accent glow borders
Split hero: display:grid 1fr 1fr + syntax-coloured terminal panel, no library
Vertical timeline: ::before gradient line + done/active/pending node states + CSS pulse
Image comparison: clip-path:inset(0 X% 0 0) drag reveal, touch support, clamped %
Masonry grid: CSS columns:3 + break-inside:avoid — native browser masonry, no JS
Chat UI: dynamic createElement message append, outgoing/incoming bubble variants

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

Above-the-fold hero sections for product and SaaS landing pages
Hero section with radial glow, animated badge, clamp() fluid headline, and dual CTAs for product landing pages. Split Hero with a terminal code panel for developer tool landing pages and API product sites. Bento Grid for feature showcase sections with mixed-size highlight cards.
Portfolio, documentation, blog, and content-rich page layouts
CSS Grid Cards for responsive article listings, documentation index pages, and tool grids. Masonry Grid for photography portfolios, design showcases, and any layout with variable-height cards. Vertical Timeline for product changelogs, company history pages, and project milestone displays.
Error pages, empty states, and zero-data screens
Empty State for dashboard widgets with no data yet, empty search results, empty cart pages, and first-use onboarding screens. The 404 Page provides a complete custom error page with animated number, description, and multiple navigation CTAs — ready to drop into any project.
Study modern CSS layout techniques — Grid, columns, clip-path
CSS Grid Cards teaches the auto-fill minmax responsive pattern — one rule, no media queries. Masonry Grid teaches CSS columns with break-inside: avoid. Image Comparison teaches clip-path: inset() for interactive reveal. Each snippet isolates a single technique you can lift and apply elsewhere.
Before/after comparison sliders for showcases and demos
Image Comparison for photo editing before/after demos, website redesign showcases, AI image enhancement comparisons, and product upgrade visuals. Full touch support via touchmove events. The drag position is clamped so both images always remain partially visible.
Pricing toggle and billing switcher sections
Pricing Toggle for SaaS monthly/annual billing pages. Two price arrays swap on toggle with a CSS knob animation. The Save 20% badge is always visible to nudge users toward the annual plan. See the Pricing category for a complete 3-tier pricing page with this toggle built in.

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.