Componentdata0.39 KB gzipZero dependencies
Masonry Columns
CSS columns masonry: cards flow by height with break-inside protection.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add masonry-columnsOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { MasonryColumns } from "@/components/ui/masonry-columns"; <MasonryColumns />Source code
masonry-columns.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxmasonry-columns.tsx34 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface MasonryItem { id: string; content: React.ReactNode;} export interface MasonryColumnsProps extends React.HTMLAttributes<HTMLDivElement> { items: MasonryItem[]; columns?: 2 | 3 | 4;} /** CSS multi-column masonry layout: dynamic height card distribution. */export function MasonryColumns({ items = [], columns = 3, className, ...props }: MasonryColumnsProps) { const colClass = { 2: "sm:columns-2", 3: "sm:columns-3", 4: "sm:columns-4" }[columns];Props
| Prop | Type | Description |
|---|---|---|
| items | MasonryItem[] | Structured list of items rendered by the component. (Default: []) |
| columns | 2 | 3 | 4 | Column definitions describing headers, cell keys, and sorting. (Default: 3) |