MasonryGrid
XS, under 350B gzippedA zero-JS masonry layout via CSS columns.
- Category
- Data display
- Budget
- xs, static display primitive
- Runtime deps
- None
Preview
Card A
Card B
This is the exact fixture the conformance suite renders in CI. Switch the language to see the component mirror and reformat.
Install
npx shadcn@latest add https://kata-ui-rho.vercel.app/r/masonry-grid.jsonCopies the source into your project. Pulls in 1 primitive: cn.
Source
import { cn } from "../lib/cn";
export interface MasonryGridProps {
children: React.ReactNode;
columns?: number;
className?: string;
}
/**
* CSS columns, not a JavaScript layout engine: this reflows correctly on
* resize and under RTL for free (browsers already fill multi-column layouts
* start-to-end, not literally left-to-right), and adds no runtime cost whatsoever.
*/
export function MasonryGrid({ children, columns = 3, className }: MasonryGridProps) {
return (
<div
className={cn("gap-4 [&>*]:mb-4 [&>*]:break-inside-avoid", className)}
style={{ columnCount: columns, columnGap: "1rem" }}
>
{children}
</div>
);
}
What CI checks
- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation