Services Grid
Landing section with a header and a grid of service cards with a cursor spotlight; one card can be featured across two columns.
pnpm dlx shadcn@latest add @leo/services-gridProps
| Name | Type | Default | Description |
|---|---|---|---|
| accentColor | string | undefined | #d97706 | Electric border colour on the featured card, hex (3 or 6 digits, e.g. "#d97706"): the border layers are derived from it, so var(), rgb() or oklch() colours drop a layer. Its opacity follows `var(--forge-glow, 1)`: on Forge themes the border fades with the theme's glow, and where --forge-glow is unset (any other site) it shows at full strength in light and dark mode alike. |
| className | string | undefined | - | |
| description | string | undefined | Five services that feed each other: the website at the centre, the brand and the care that keep it sharp. | |
| eyebrow | string | undefined | Services | |
| items | ServiceCardItem[] | undefined | [ { title: "Custom websites", description: "Designed from a blank page and built by hand: no template, no page-builder lock-in, and the full source is yours.", tags: ["Next.js", "CMS", "SEO"], href: "#", featured: true, }, { title: "Brand identity", description: "A mark, a palette and a voice that hold up on a shop sign and a social avatar alike.", tags: ["Logo", "Guidelines"], href: "#", }, { title: "Sales kits", description: "Decks, one-pagers and price sheets your team can send without asking us first.", tags: ["Decks", "Print"], href: "#", }, { title: "Launch video", description: "A 30-second cut for the landing page and the same footage re-framed for social.", tags: ["Motion", "Social"], href: "#", }, { title: "Hosting & care", description: "Fast hosting, backups and monthly updates, so the site you shipped stays that way.", tags: ["Hosting", "Backups"], href: "#", }, ] | Omit for the sample cards; an empty array renders no cards. |
| linkComponent | ElementType<{ href: string; className?: string | undefined; children?: ReactNode; }, keyof IntrinsicElements> | undefined | a | Link element for cards with href, e.g. next/link. Receives href, className and children. |
| linkLabel | string | undefined | Learn more | Shown at the bottom of linked cards; empty string hides it. |
| reducedMotion | undefined | "respect" | "ignore" | respect | "ignore" keeps the electric border animating for visitors who prefer reduced motion. |
| spotlightColor | `rgba(${number}, ${number}, ${number}, ${number})` | undefined | - | Hover glow; omit to derive it from accentColor at low alpha. |
| title | string | undefined | What we make, and keep running | Empty string hides the whole header (eyebrow and description too), for sites that render their own. |
Source
"use client";
import type React from "react";
import ElectricBorder from "@/components/electric-border";
import SpotlightCard, { type SpotlightCardProps } from "@/components/spotlight-card";
import { useForgeMotion } from "@/hooks/use-forge-motion";
import { cn } from "@/lib/utils";
export interface ServiceCardItem {
title: string;
description?: string;
tags?: string[];
/** The whole card becomes a link when set. */
href?: string;
/** Spans two columns from md up, with a larger title, a primary hairline and wash, and an electric border (not rendered under reduced motion in "respect" mode). */
featured?: boolean;
}
export interface ServicesGridProps {
eyebrow?: string;
/** Empty string hides the whole header (eyebrow and description too), for sites that render their own. */
title?: string;
description?: string;
/** Omit for the sample cards; an empty array renders no cards. */
items?: ServiceCardItem[];
/** Shown at the bottom of linked cards; empty string hides it. */
linkLabel?: string;
/** Link element for cards with href, e.g. next/link. Receives href, className and children. */
linkComponent?: React.ElementType<{
href: string;
className?: string;
children?: React.ReactNode;
}>;
/** Hover glow; omit to derive it from accentColor at low alpha. */
spotlightColor?: SpotlightCardProps["spotlightColor"];
/** Electric border colour on the featured card, hex (3 or 6 digits, e.g. "#d97706"): the border layers are derived from it, so var(), rgb() or oklch() colours drop a layer. Its opacity follows `var(--forge-glow, 1)`: on Forge themes the border fades with the theme's glow, and where --forge-glow is unset (any other site) it shows at full strength in light and dark mode alike. */
accentColor?: string;
/** "ignore" keeps the electric border animating for visitors who prefer reduced motion. */
reducedMotion?: "respect" | "ignore";
className?: string;
}
const SAMPLE_ITEMS: ServiceCardItem[] = [
{
title: "Custom websites",
description:
"Designed from a blank page and built by hand: no template, no page-builder lock-in, and the full source is yours.",
tags: ["Next.js", "CMS", "SEO"],
href: "#",
featured: true,
},
{
title: "Brand identity",
description:
"A mark, a palette and a voice that hold up on a shop sign and a social avatar alike.",
tags: ["Logo", "Guidelines"],
href: "#",
},
{
title: "Sales kits",
description: "Decks, one-pagers and price sheets your team can send without asking us first.",
tags: ["Decks", "Print"],
href: "#",
},
{
title: "Launch video",
description: "A 30-second cut for the landing page and the same footage re-framed for social.",
tags: ["Motion", "Social"],
href: "#",
},
{
title: "Hosting & care",
description:
"Fast hosting, backups and monthly updates, so the site you shipped stays that way.",
tags: ["Hosting", "Backups"],
href: "#",
},
];
function CardBody({ item, index }: { item: ServiceCardItem; index: number }) {
return (
<>
{/* Decorative index, hidden from assistive tech. */}
<span aria-hidden="true" className="font-mono text-xs text-primary">
{String(index + 1).padStart(2, "0")}
</span>
<h3
className={cn(
"font-[family-name:var(--font-heading)] text-xl font-semibold tracking-tight",
item.featured && "text-2xl sm:text-3xl",
)}
>
{item.title}
</h3>
{item.description && (
<p className="text-sm leading-relaxed text-muted-foreground sm:text-base">
{item.description}
</p>
)}
{item.tags && item.tags.length > 0 && (
<ul className="flex flex-wrap gap-2">
{item.tags.map((tag, tagIndex) => (
<li
// biome-ignore lint/suspicious/noArrayIndexKey: tags have no id and may repeat, so the index is part of the key
key={`${tagIndex}-${tag}`}
className="border border-border px-2 py-0.5 font-mono text-[0.7rem] tracking-wider text-muted-foreground uppercase"
>
{tag}
</li>
))}
</ul>
)}
</>
);
}
export default function ServicesGrid({
eyebrow = "Services",
title = "What we make, and keep running",
description = "Five services that feed each other: the website at the centre, the brand and the care that keep it sharp.",
items = SAMPLE_ITEMS,
linkLabel = "Learn more",
linkComponent: Link = "a",
spotlightColor,
accentColor = "#d97706",
reducedMotion = "respect",
className,
}: ServicesGridProps) {
const { animate } = useForgeMotion(reducedMotion);
// The spotlight is a CSS gradient stop, so color-mix() is valid even though the prop type only names rgba().
const glow =
spotlightColor ??
(`color-mix(in srgb, ${accentColor} 15%, transparent)` as SpotlightCardProps["spotlightColor"]);
return (
<section className={cn("bg-background px-6 py-16 text-foreground sm:py-24", className)}>
<div className="mx-auto max-w-6xl">
{title && (
<header className="mb-12 max-w-2xl">
{eyebrow && (
<p className="font-mono text-xs tracking-widest text-primary uppercase">{eyebrow}</p>
)}
<h2 className="mt-3 font-[family-name:var(--font-heading)] text-3xl font-semibold tracking-tight sm:text-4xl">
{title}
</h2>
{description && <p className="mt-4 text-base text-muted-foreground">{description}</p>}
</header>
)}
{items.length > 0 && (
// biome-ignore lint/a11y/noRedundantRoles: Tailwind's list-style: none makes Safari/VoiceOver drop list semantics; role restores them.
<ul role="list" className="grid border-t border-l border-border md:grid-cols-2">
{items.map((item, index) => (
<li
// biome-ignore lint/suspicious/noArrayIndexKey: items have no id and titles may repeat, so the index is part of the key
key={`${index}-${item.title}`}
data-featured={item.featured ? "" : undefined}
className={cn(
"relative flex border-r border-b border-border",
item.featured && "md:col-span-2",
)}
>
<SpotlightCard
spotlightColor={glow}
// Cells share borders, so they cannot round individually: the grid stays square on every theme.
// border-border only replaces SpotlightCard's hard-coded neutral border colour.
className={cn(
"flex w-full flex-col rounded-none border-0 border-border bg-card p-0 text-card-foreground",
item.featured && "bg-primary/5",
)}
>
{item.href ? (
<Link
href={item.href}
// z-[1] lifts the link (and its focus outline) above the featured card's electric-border overlay, which follows the card in DOM order.
className="relative z-[1] flex h-full flex-col gap-4 p-6 outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-ring focus-visible:-outline-offset-[6px] sm:p-8"
>
<CardBody item={item} index={index} />
{linkLabel && (
<span className="mt-auto pt-2 font-mono text-xs tracking-widest text-primary uppercase">
{linkLabel} <span aria-hidden="true">ā</span>
</span>
)}
</Link>
) : (
<div className="relative flex h-full flex-col gap-4 p-6 sm:p-8">
<CardBody item={item} index={index} />
</div>
)}
</SpotlightCard>
{item.featured && (
<>
<span
aria-hidden="true"
className="pointer-events-none absolute inset-x-0 top-0 h-0.5 bg-primary"
/>
{animate && (
<span aria-hidden="true" className="pointer-events-none absolute inset-0">
<ElectricBorder
color={accentColor}
borderRadius={0}
className="pointer-events-none absolute inset-0"
style={{ opacity: "var(--forge-glow, 1)" }}
/>
</span>
)}
</>
)}
</li>
))}
</ul>
)}
</div>
</section>
);
}