Gallery: project grid
A two-column project collection with image placeholders and optional detail links.
pnpm dlx shadcn@latest add @haze/gallery-project-grid---
import { ArrowUpRight } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
import Placeholder from "../ui/placeholder.astro";
interface Props {
id?: string;
eyebrow?: string;
title?: string;
description?: string;
headingLevel?: 1 | 2 | 3;
projects?: { title: string; category: string; visual: "app" | "chart" | "photo"; href?: string }[];
class?: string;
}
const {
id = "gallery-project-grid",
eyebrow = "Selected work",
title = "A few ways ideas can take shape",
description = "An example collection of projects, with illustrations standing in for finished work.",
headingLevel = 2,
projects = [
{ title: "A calmer project home", category: "Workspace", visual: "app" },
{ title: "A view of the week ahead", category: "Planning", visual: "chart" },
{ title: "A shared place for decisions", category: "Collaboration", visual: "app" },
{ title: "A clearer progress report", category: "Reporting", visual: "chart" },
],
class: className,
} = Astro.props;
const Heading = ({ 1: "h1", 2: "h2", 3: "h3" } as const)[headingLevel];
const ProjectHeading = ({ 1: "h2", 2: "h3", 3: "h4" } as const)[headingLevel];
---
<section aria-labelledby={`${id}-title`} class={cn("bg-background px-6 py-20 sm:py-24", className)}>
<div class="mx-auto max-w-6xl">
<div class="max-w-2xl">
<p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">{eyebrow}</p>
<Heading id={`${id}-title`} class="mt-3 text-3xl/9 font-semibold tracking-tight text-balance text-foreground sm:text-4xl/11">{title}</Heading>
<p class="mt-4 text-base/7 text-pretty text-muted-foreground">{description}</p>
</div>
<ul class="mt-12 grid gap-x-6 gap-y-10 sm:grid-cols-2">
{projects.map((project) => (
<li class="min-w-0">
<Placeholder variant={project.visual} class="aspect-[4/3]" />
<div class="mt-4 flex items-start justify-between gap-4">
<div>
<p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">{project.category}</p>
<ProjectHeading class="mt-1 text-base/6 font-semibold tracking-tight text-foreground">
{project.href ? <a href={project.href} class="rounded-sm transition-colors duration-150 ease-snappy hover:text-foreground/80 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">{project.title}<span class="sr-only">: view project</span></a> : project.title}
</ProjectHeading>
</div>
{project.href && <ArrowUpRight aria-hidden="true" class="mt-2 size-4 shrink-0 text-muted-foreground" />}
</div>
</li>
))}
</ul>
</div>
</section>When to use
- Presenting several projects with equal prominence
- Each item needs a category and an optional link to its full story
When not to use
- The entries are written articles with dates and authors; use blog-featured-stories
Installation
Add the Haze registry to components.json once, then install Gallery: project grid with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/gallery-project-gridnpx shadcn@latest add @haze/gallery-project-gridyarn dlx shadcn@latest add @haze/gallery-project-gridbunx --bun shadcn@latest add @haze/gallery-project-gridFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "gallery-project-grid" | Unique section ID prefix. |
| eyebrow | string | "Selected work" | Label above the title. |
| title | string | demo heading | Heading for the collection. |
| description | string | demo copy | Introduction; the default identifies the illustrations as examples. |
| headingLevel | 1 | 2 | 3 | 2 | Section heading level; project headings use the next level. |
| projects | { title: string; category: string; visual: "app" | "chart" | "photo"; href?: string }[] | 4 example projects | Project labels, decorative visual variants and optional destinations. |
| class | string | – | Additional section classes. |
Keyboard interactions
- Tab, Enter
- Focus and open project links when provided.
Accessibility
- Each project has a heading and category; the placeholder artwork is decorative.
- A title becomes a descriptive link only when its project has a destination.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Gallery: project grid" with `npx shadcn@latest add @haze/gallery-project-grid`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import GalleryProjectGrid from "@/components/haze/blocks/gallery-project-grid.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/gallery-project-grid.md
Customize with real content
Adapt the Haze gallery-project-grid block for our product. Replace the demo values of these props with our real content: id, eyebrow, title, description, headingLevel, projects, class. Keep the layout, the heading level rules and these accessibility details: Each project has a heading and category; the placeholder artwork is decorative. A title becomes a descriptive link only when its project has a destination. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using gallery-project-grid, check it fits: use it when presenting several projects with equal prominence; each item needs a category and an optional link to its full story. Avoid it when the entries are written articles with dates and authors; use blog-featured-stories. Alternatives: @haze/blog-featured-stories.
Dependencies
- npm: @lucide/astro
- @haze/placeholder
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.