CSS Masonry
Pure CSS multi-column responsive masonry layout with zero external JavaScript runtime overhead.
Interactive Specification & Studio
Zero Layout Shift
Deterministic layout calculation
Hermite Spline Acceleration
Nonlinear velocity curves preserving fluid frame timing during continuous inertial scrolling.
CSS multi-column executes directly on the compositor thread with zero JavaScript runtime overhead.
Runge-Kutta 4th Order
Micro-interaction spring simulation with RK4 numerical integration.
column-count: 1;
break-inside: avoid;
column-fill: balance;Spatial Void Elimination
Staggered elements interlock fluidly to eliminate vertical blank gaps across varying column heights.
DOM Order Flow Integrity
Keyboard tab sequence preserved
Quick Start & Consumer Example
Copy-paste ready implementation for React (.tsx). Automatically updates when you modify parameters in the Workbench above.
import React from 'react';
import { CssMasonry } from '@/components/ui/CssMasonry';
const TILES = [
{ id: '01', title: 'Quantum Sub-Pixel Masonry', desc: 'Hardware-composited multi-column tracks with zero reflow penalties.', heightClass: 'h-48', tag: '01 // GPU' },
{ id: '02', title: 'Continuous Fluid Flow', desc: 'Elements cascade naturally across column partitions without clipping.', heightClass: 'h-64', tag: '02 // CASCADE' },
{ id: '03', title: 'Break-Inside Isolation', desc: 'Native CSS fragmentation protection preventing boundary fracture.', heightClass: 'h-40', tag: '03 // ISOLATION' },
{ id: '04', title: 'Sequential Auto Waterfall', desc: 'Height-bounded deterministic layout filling columns in priority sequence.', heightClass: 'h-72', tag: '04 // WATERFALL' },
{ id: '05', title: 'Adaptive Breakpoints', desc: 'Container-aware column scaling spanning mobile (1 col) to ultra-wide (4+ cols).', heightClass: 'h-52', tag: '05 // ADAPTIVE' },
{ id: '06', title: 'Memory-Safe Lifecycle', desc: 'Stateless declarative container with zero persistent listeners.', heightClass: 'h-44', tag: '06 // ZERO-LEAK' },
{ id: '07', title: 'Universal Compilation', desc: 'Single unified layout engine compiled for all 13 supported ecosystems.', heightClass: 'h-60', tag: '07 // CROSS-PLATFORM' },
{ id: '08', title: 'Sub-Millisecond V-Sync', desc: 'Zero JavaScript execution during scroll, guaranteeing 120 FPS render.', heightClass: 'h-48', tag: '08 // V-SYNC' },
];
export function CssMasonryDemo() {
return (
<section className="p-8 bg-background text-foreground">
<CssMasonry
columns={1}
columnsSm={2}
columnsMd={2}
columnsLg={3}
columnsXl={4}
gap={16}
columnFill="balance"
className="max-w-6xl mx-auto"
>
{TILES.map((tile) => (
<div
key={tile.id}
className={`${tile.heightClass} rounded-2xl border border-border/80 bg-card p-6 shadow-xs flex flex-col justify-between`}
>
<div>
<span className="text-3xs font-mono font-bold text-primary">{tile.tag}</span>
<h3 className="font-bold text-base mt-2">{tile.title}</h3>
<p className="text-muted-foreground text-xs mt-2">{tile.desc}</p>
</div>
<div className="pt-3 border-t border-border/40 flex justify-between text-3xs font-mono text-muted-foreground">
<span>TILE #{tile.id}</span>
<span className="text-emerald-400 font-bold">120 FPS</span>
</div>
</div>
))}
</CssMasonry>
</section>
);
}
Props & Configuration
Exhaustive parameter contract for CSS Masonry. Validated in the live Studio workbench above and statically checked across all 13 ecosystem templates.
| Prop | Type | Default | Description |
|---|---|---|---|
columns | number | 1 | Base column count on mobile viewports (<640px). |
columnsSm | number | 2 | Number of columns on tablet viewports (≥640px). |
columnsMd | number | 2 | Number of columns on medium tablet viewports. |
columnsLg | number | 3 | Number of columns on desktop viewports. |
columnsXl | number | 4 | Number of columns on large screens (≥1280px). |
gap | number | 16 | Spacing between masonry columns and item margins. |
columnFill | select | balance | Controls whether column heights are balanced or filled sequentially. |
height | number | 0 | Explicit container height for sequential waterfall (0 for auto balance). |
Base column count on mobile viewports (<640px).
Number of columns on tablet viewports (≥640px).
Number of columns on medium tablet viewports.
Number of columns on desktop viewports.
Number of columns on large screens (≥1280px).
Spacing between masonry columns and item margins.
Controls whether column heights are balanced or filled sequentially.
Explicit container height for sequential waterfall (0 for auto balance).
Component Source
Component source definition for React (.tsx). Toggle between the clean wrapper and the standalone ejected engine micro-kernel.
import * as React from 'react';
import * as CssMasonryPrimitive from '@exhuma/core';
import { clsx } from 'clsx';
export interface CssMasonryProps extends React.ComponentPropsWithoutRef<typeof CssMasonryPrimitive.CssMasonry> {
className?: string;
}
export const CssMasonry = React.forwardRef<HTMLDivElement, CssMasonryProps>(
({ className, children, ...props }, ref) => (
<CssMasonryPrimitive.CssMasonry
ref={ref}
className={clsx(
'columns-1 sm:columns-2 md:columns-3 gap-4 [column-fill:_balance] w-full space-y-4',
className
)}
{...props}
>
{children}
</CssMasonryPrimitive.CssMasonry>
)
);
CssMasonry.displayName = 'CssMasonry';
export const CssMasonryItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, children, ...props }, ref) => (
<CssMasonryPrimitive.CssMasonryItem
ref={ref}
className={clsx('', className)}
{...props}
>
{children}
</CssMasonryPrimitive.CssMasonryItem>
)
);
CssMasonryItem.displayName = 'CssMasonryItem';
Lifecycle Safety & Performance
Engineered for high-frequency user interactions with zero memory leaks.
Deterministic Cleanup
GPU Compositor Acceleration
will-change: transform without triggering browser layout recalculations.Accessibility Considerations
Fully compliant with WCAG guidelines and respects user motion preferences.
prefers-reduced-motion Support
prefers-reduced-motion: reduce enabled in their operating system, Exhuma components automatically disable 3D gyroscope tilt and spring animations, rendering static accessible content.