Glass Icon Feature Grid
Dark feature grid of six glass cards for a landing page: a centered eyebrow and heading over a full-bleed Panel scene, with each frosted card holding a light icon, a title and a short description.
import {
BracketsCurlyIcon,
ClockCounterClockwiseIcon,
GitMergeIcon,
HourglassMediumIcon,
SealCheckIcon,
VaultIcon,
} from "@phosphor-icons/react/ssr"
import { Eyebrow } from "@/components/eyebrow/eyebrow"
import { Grid } from "@/components/grid/grid"
import { PanelScene } from "@/components/scene/panel-scene"
import {
Section,
SectionBackground,
SectionContent,
SectionDescription,
SectionHeader,
SectionTitle,
} from "@/components/section/section"
// The copy: change text here, not in the markup.
const COPY = {
eyebrow: "Infrastructure",
title: "The foundation runs itself",
body: "Deploys, certificates, background jobs and backups follow best practices without a runbook.",
} as const
const FEATURES = [
{
icon: GitMergeIcon,
name: "Continuous deploys",
description:
"A merge to main starts a build and releases it once the checks pass. Nobody has to remember a deploy step.",
},
{
icon: SealCheckIcon,
name: "Automatic TLS",
description:
"A domain receives a certificate when it is added and a fresh one well before expiry, so traffic stays encrypted from day one.",
},
{
icon: HourglassMediumIcon,
name: "Queued work",
description:
"Exports, emails and other slow tasks run outside the request, which keeps pages fast and timeouts rare.",
},
{
icon: VaultIcon,
name: "Layered security",
description:
"Roles control access, an audit log records each change, and data at rest is encrypted.",
},
{
icon: BracketsCurlyIcon,
name: "Scriptable dashboard",
description:
"Dashboard actions are available through a typed, documented API, ready for your own automation.",
},
{
icon: ClockCounterClockwiseIcon,
name: "Point-in-time recovery",
description:
"Scheduled snapshots let you return the database to a chosen moment in a handful of steps.",
},
] as const
export default function GlassIconFeatureGrid() {
return (
<Section className="dark overflow-hidden">
<SectionBackground className="overflow-hidden">
<PanelScene />
</SectionBackground>
<SectionHeader align="center" className="text-shadow-legible">
<Eyebrow className="text-foreground">{COPY.eyebrow}</Eyebrow>
<SectionTitle>{COPY.title}</SectionTitle>
<SectionDescription className="text-inherit">
{COPY.body}
</SectionDescription>
</SectionHeader>
<SectionContent className="relative">
<Grid
render={<ul role="list" />}
cols={3}
gap="sm"
className="md:grid-cols-2 min-[56rem]:grid-cols-3"
>
{FEATURES.map((feature) => (
// A glass tile that is the feature itself, not a Card. Its corner
// reads --box-radius (globals.css), so it follows the shadcn
// style. --tile-padding steps up with the section.
<li
key={feature.name}
className="flex flex-col gap-(--tile-padding) overflow-hidden rounded-(--box-radius) surface-glass py-(--tile-padding) text-base/7 [--tile-padding:--spacing(8)] sm:min-h-64 sm:[--tile-padding:--spacing(10)]"
>
<div className="grid px-(--tile-padding)">
<feature.icon
className="size-7"
weight="light"
aria-hidden="true"
/>
</div>
<div className="mt-auto flex flex-col gap-2 px-(--tile-padding)">
<h3 className="font-medium">{feature.name}</h3>
<p className="text-pretty text-current/75 not-italic">
{feature.description}
</p>
</div>
</li>
))}
</Grid>
</SectionContent>
</Section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const eyebrowVariants = cva("text-eyebrow", {
variants: {
/**
* `default` is a 14px/20px label. `icon` adds a row with a 16px icon
* and a 12px gap; put the icon first and give it `aria-hidden`.
* `mono` is a 12px/20px label in the mono face, in sentence case like
* the others: the kit sets no label in capitals.
*/
variant: {
default: "text-sm/5 font-medium text-eyebrow",
icon: "flex items-center gap-3 text-sm/5 font-medium [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
mono: "font-mono text-xs/5 font-medium",
},
},
defaultVariants: { variant: "default" },
})
/**
* A short label above a heading, rendered as a `<p>` at weight 500.
* The default is 14px/20px in the kit's eyebrow color. The surrounding
* layout controls the space to the heading. Use `className` to customize
* the typography or color, and `render` to change the element: a `p` is
* right when the label stands alone as a line of text; pass
* `render={<span />}` or `render={<div />}` when it sits inside a heading,
* link, button or other inline text, where a `p` is not valid HTML.
*/
function Eyebrow({
className,
variant = "default",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof eyebrowVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "eyebrow", variant },
props: mergeProps<"p">(
{ className: cn(eyebrowVariants({ variant }), className) },
props
),
})
}
export { Eyebrow, eyebrowVariants }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const GRID_DEFAULTS = { cols: 3, gap: "lg" } as const
const containerGridVariants = cva("grid w-full grid-cols-1", {
variants: {
/**
* The most columns. Below 40rem of screen width the grid is one
* column (two for `6`); it steps up at 40rem and 48rem: `2` is two
* columns from 40rem, `3` two then three, `4` two then four, `5` three
* then five, and `6` three, then four, then six from 64rem. The default
* is 3.
*/
cols: {
1: "",
2: "sm:grid-cols-2",
3: "sm:grid-cols-2 md:grid-cols-3",
4: "sm:grid-cols-2 md:grid-cols-4",
5: "sm:grid-cols-3 md:grid-cols-5",
6: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6",
},
/**
* Space between items: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default. The sizes are the `--gap-*` values in globals.css.
*/
gap: {
xs: "gap-(--gap-xs)",
sm: "gap-(--gap-sm)",
md: "gap-(--gap-md)",
lg: "gap-(--gap-lg)",
xl: "gap-(--gap-xl)",
px: "gap-px",
none: "gap-0",
},
},
defaultVariants: GRID_DEFAULTS,
})
type GridState = { slot: "grid" } & VariantProps<typeof containerGridVariants>
type GridProps = useRender.ComponentProps<"div", GridState> &
VariantProps<typeof containerGridVariants>
/**
* Columns follow the screen, stepping at 40rem and 48rem (and 64rem for six).
* Gap sizes read the shared `--gap-*` values in globals.css. The grid fills
* its parent's width: without that, a grid given `mx-auto` or set inside a
* centering parent shrinks to fit its content, and a part built on it that
* is a container collapses to nothing.
*
* className, render and every other prop go to the grid. To narrow a Grid, pass
* a `max-w-*` class or size its parent.
*/
function Grid({
className,
cols = GRID_DEFAULTS.cols,
gap = GRID_DEFAULTS.gap,
render,
...props
}: GridProps) {
const grid = useRender({
defaultTagName: "div",
render,
state: { slot: "grid", cols, gap },
props: mergeProps<"div">(
{ className: cn(containerGridVariants({ cols, gap }), className) },
props
),
})
return grid
}
export { Grid, type GridProps }
import { cn } from "cn"
import { shift, type OklchColor } from "@/lib/field-layers"
// Paper grain: an SVG turbulence filter as a data URI.
const PAPER_GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250' viewBox='0 0 100 100'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='turbulence' baseFrequency='1.4' numOctaves='1' seed='2' stitchTiles='stitch' result='n'/%3E%3CfeComponentTransfer result='g'%3E%3CfeFuncR type='linear' slope='4' intercept='1'/%3E%3CfeFuncG type='linear' slope='4' intercept='1'/%3E%3CfeFuncB type='linear' slope='4' intercept='1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='saturate' values='0' in='g'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`
type PanelPaletteShape = {
/** Ground color — every column fades to this at the bottom. */
base: OklchColor
/**
* Top of the center (brightest) column — edges derive via a lightness drop.
*/
center: OklchColor
/** Light-source glow at the top-center (rendered at 40% alpha). */
glow: OklchColor
}
const PALETTES = {
teal: {
base: { l: 0.1, c: 0.01, h: 250 },
center: { l: 0.4, c: 0.045, h: 220 },
glow: { l: 0.46, c: 0.06, h: 235 },
},
} as const satisfies Record<string, PanelPaletteShape>
type PanelPalette = keyof typeof PALETTES
type PanelColors = Partial<PanelPaletteShape>
function fmt(c: OklchColor, alpha?: number): string {
const a = alpha != null ? ` / ${alpha}` : ""
return `oklch(${c.l} ${c.c} ${c.h}${a})`
}
const COLUMN_COUNT = 9
/**
* Nine vertical stripes fading from a lit top to a dark base, brightest at the
* center, with a top glow and grain. Full-bleed art layer: drop it inside a
* `relative` parent; it sits behind content.
*/
function PanelScene({
palette = "teal",
colors,
className,
grain = true,
style,
...props
}: Omit<React.ComponentProps<"div">, "children"> & {
/** Set false when stacking your own grain on top. */
grain?: boolean
/** The preset colors; `teal` is the only one so far. */
palette?: PanelPalette
/** OKLCH overrides for the `base`, the `center` column and the `glow`. */
colors?: PanelColors
}) {
const palBase = PALETTES[palette]
const base = colors?.base ?? palBase.base
const center = colors?.center ?? palBase.center
const glow = colors?.glow ?? palBase.glow
const halfSpan = (COLUMN_COUNT - 1) / 2
const columns = Array.from({ length: COLUMN_COUNT }, (_, i) => {
const t = Math.abs(i - halfSpan) / halfSpan
return shift(center, -0.1 * t, -0.005 * t, 0)
})
return (
<div
className={cn("pointer-events-none absolute inset-0", className)}
aria-hidden="true"
style={{ background: fmt(base), ...style }}
data-slot="panel-scene"
{...props}
>
<div
className="absolute inset-0"
style={{
mask: "linear-gradient(0deg in srgb, oklch(0 0 0 / 0) 0%, oklch(0 0 0 / 1) 55%)",
}}
>
{/* Grid not flex — flex subpixel rounding bled the last column 1px. */}
<div
className="absolute inset-0 grid"
style={{ gridTemplateColumns: `repeat(${COLUMN_COUNT}, 1fr)` }}
>
{columns.map((from, i) => (
<div
key={i}
style={{
background: `linear-gradient(to bottom, ${fmt(from)} 0%, ${fmt(base)} 100%)`,
}}
/>
))}
</div>
<div
className="absolute inset-x-0 top-0 h-1/2"
style={{
background: `radial-gradient(ellipse 60% 80% at 50% 0%, ${fmt(glow, 0.4)} 0%, transparent 70%)`,
}}
/>
</div>
{grain && (
<div
className="absolute inset-0 opacity-20 mix-blend-overlay"
style={{ backgroundImage: PAPER_GRAIN }}
/>
)}
</div>
)
}
export { PanelScene }
export type { OklchColor as PanelOklch }
// The OKLCH math the painted scenes share: a color, a shift of it and its
// CSS string, used across components/scene; plus the two blurred fields over
// a ground that ColorFieldWash and HorizonGlazeScene build from three anchors.
// Plain functions, no React, so a scene can also precompute its palettes.
export type OklchColor = { l: number; c: number; h: number }
/** The three colors a field is painted from. */
export type FieldAnchors = {
ground: OklchColor
upper: OklchColor
lower: OklchColor
}
/** The CSS backgrounds built from the anchors. */
export type FieldLayers = {
ground: string
upper: string
lower: string
}
export function shift(base: OklchColor, dl = 0, dc = 0, dh = 0): OklchColor {
return {
l: Math.max(0, Math.min(1, base.l + dl)),
c: Math.max(0, base.c + dc),
h: (base.h + dh + 360) % 360,
}
}
export function fmt(c: OklchColor, alpha?: number): string {
const l = Math.round(c.l * 1000) / 1000
const ch = Math.round(c.c * 1000) / 1000
const h = Math.round(c.h * 10) / 10
const a = alpha != null ? ` / ${alpha}` : ""
return `oklch(${l} ${ch} ${h}${a})`
}
export const clean = <T extends object>(o: T) =>
Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as T
// Upper field: a little darker, duller and cooler toward its edge; lower
// field the same, more so. The geometry matches the hand-tuned palettes
// that share this shape.
export function buildFieldLayers(a: FieldAnchors): FieldLayers {
return {
ground: fmt(a.ground),
upper: `radial-gradient(ellipse 130% 100% at 50% 35%, ${fmt(a.upper)} 0%, ${fmt(shift(a.upper, -0.025, -0.003, -3), 0.7)} 55%, transparent 100%)`,
lower: `radial-gradient(ellipse 130% 90% at 50% 80%, ${fmt(a.lower)} 0%, ${fmt(shift(a.lower, -0.03, -0.009, -1.5), 0.8)} 55%, transparent 100%)`,
}
}
/**
* The anchors behind a palette written as CSS: the ground and the first
* `oklch()` stop of each field. Lets a scene seed its overrides from a
* palette it already has as strings, so the numbers live once.
*/
export function firstStops(p: FieldLayers): FieldAnchors {
const first = (css: string): OklchColor => {
const m = /oklch\(([\d.]+) ([\d.]+) ([\d.]+)/.exec(css)
if (!m) throw new Error(`field-layers: no oklch() stop in ${css}`)
return { l: Number(m[1]), c: Number(m[2]), h: Number(m[3]) }
}
return {
ground: first(p.ground),
upper: first(p.upper),
lower: first(p.lower),
}
}
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const sectionVariants = cva(
"relative isolate w-full bg-background wrap-anywhere text-foreground",
{
variants: {
/**
* The padding above and below: `sm` 64px (96px from `lg`), `md` (the
* default) 72px (120px from `lg`), `lg` 80px (144px from `lg`).
*/
size: {
sm: "py-16 lg:py-24",
md: "py-18 lg:py-30",
lg: "py-20 lg:py-36",
},
},
defaultVariants: { size: "md" },
}
)
// The gap between the band's children, by the band's size: 40px, and 64px
// from `sm` for `md`; 64px for `lg`.
const columnVariants = cva(
"mx-auto flex w-full max-w-[90.5rem] min-w-0 flex-col px-4 sm:px-6",
{
variants: {
size: {
sm: "gap-10",
md: "gap-10 sm:gap-16",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
}
)
/**
* A page band: a full-width `<section>` holding a centered column, 1400px
* of content with 16px sides on a phone and 24px from `sm`. `size` sets its
* padding and the gap between its children.
*/
function Section({
className,
size = "md",
children,
...props
}: ComponentProps<"section"> & VariantProps<typeof sectionVariants>) {
return (
<section
data-slot="section"
data-size={size}
className={cn(sectionVariants({ size }), className)}
{...props}
>
<div data-slot="section-column" className={columnVariants({ size })}>
{children}
</div>
</section>
)
}
/** Art behind the whole band, hidden from assistive tech. */
function SectionBackground({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-background"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0 -z-10", className)}
{...props}
/>
)
}
const contentVariants = cva("mx-auto flex w-full min-w-0 flex-col", {
variants: {
/** The gap between children: `sm` 24px, `md` (the default) 32px, `lg` 64px. */
size: {
sm: "gap-6",
md: "gap-8",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
})
/**
* A centered column for the band's content, its children stacked with a
* gap. Give it a `max-w-*` class for a narrower column. Pass `render` to
* use another element.
*/
function SectionContent({
className,
size = "md",
render,
...props
}: useRender.ComponentProps<"div"> & VariantProps<typeof contentVariants>) {
return useRender({
defaultTagName: "div",
render,
state: { slot: "section-content" },
props: mergeProps<"div">(
{ className: cn(contentVariants({ size }), className) },
props
),
})
}
const columnsVariants = cva("grid w-full grid-cols-1 items-start gap-16", {
variants: {
/**
* From `lg`: `equal` (the default) two even columns; `intro` a narrower
* first column, 2:3.
*/
variant: {
equal: "lg:grid-cols-2",
intro: "lg:grid-cols-[2fr_3fr]",
},
},
defaultVariants: { variant: "equal" },
})
/** Two columns from `lg`, stacked below it, 64px apart. */
function SectionColumns({
className,
variant = "equal",
...props
}: ComponentProps<"div"> & VariantProps<typeof columnsVariants>) {
return (
<div
data-slot="section-columns"
data-variant={variant}
className={cn(columnsVariants({ variant }), className)}
{...props}
/>
)
}
const headerVariants = cva("group/section-header grid w-full min-w-0", {
variants: {
/** `start` (the default) or `center`, which centers everything in it. */
align: {
start: "",
center: "justify-items-center text-center",
},
/**
* `stack` (the default) is one column, its children 16px apart.
* `split` puts the second child, such as SectionActions, on the right
* from `sm`, level with the bottom of the first, and 24px under it
* below `sm`.
*/
variant: {
stack: "gap-4",
split: "justify-items-start gap-6 sm:grid-cols-[1fr_auto] sm:items-end",
},
},
defaultVariants: { align: "start", variant: "stack" },
})
/**
* The band's heading area. Its children are an optional Eyebrow, then
* SectionTitle, SectionDescription and SectionActions, 16px apart, with
* 24px above the actions. `variant="split"` takes two children and puts
* the second on the right; when the left side is more than a title, group
* it in a SectionHeader of its own. It has no max width, so a title runs
* the column; the description's width is its own (45rem).
*/
function SectionHeader({
className,
align = "start",
variant = "stack",
...props
}: ComponentProps<"div"> & VariantProps<typeof headerVariants>) {
return (
<div
data-slot="section-header"
data-align={align}
data-variant={variant}
className={cn(headerVariants({ align, variant }), className)}
{...props}
/>
)
}
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const sectionTitleVariants = cva("font-display font-[450] text-pretty", {
variants: {
/**
* `default` keeps the surrounding display face, tracked -0.05em and
* -0.06em from `sm`. `serif` uses the kit's serif face, tracked
* -0.03em.
*/
variant: {
default: "tracking-[-0.05em] sm:tracking-[-0.06em]",
serif: "tracking-[-0.03em] [--font-display:var(--font-serif)]",
},
/**
* `xl` (the default): 32px/40px, 56px/56px from `lg`, the section
* title. `closing`: 40px/48px, 48px/56px from `lg`, for a closing or
* side title. `lg`: 32px/40px, 40px/48px from `sm`,
* 48px/56px from `lg`. `md`: 32px/40px, capped at 40px/44px from `sm`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 lg:text-[3.5rem]/14",
closing: "text-[2.5rem]/12 lg:text-5xl/14",
},
},
defaultVariants: { variant: "default", size: "xl" },
})
/**
* A section's title in the display font, an `<h2>` at weight 450. The
* default `size="xl"` is 32px/40px, then 56px/56px from `lg`. Choose
* `size="closing"` for a closing or side title, 40px/48px then 48px/56px
* at `lg`; `size="lg"` for 32px/40px, 40px/48px at `sm` and 48px/56px at
* `lg`; or `size="md"` for 32px/40px, capped at 40px/44px from `sm`.
* `variant="serif"` uses the kit's serif face with its own, looser
* tracking. Pass `render` to use another heading level. A page's headline
* is `Heading`.
*/
function SectionTitle({
className,
variant = "default",
size = "xl",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof sectionTitleVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "section-title", variant, size },
props: mergeProps<"h2">(
{ className: cn(sectionTitleVariants({ variant, size }), className) },
props
),
})
}
/**
* The text under a section's title, a `<p>` in the muted text color:
* 16px/24px, then 18px/28px from `lg`, with balanced lines. It has no
* width of its own: give it a `max-w-*` class where it's used, or let the
* layout set the measure. A `text-*` color class replaces the color. Pass
* `render` to use another element.
*/
function SectionDescription({
className,
render,
...props
}: useRender.ComponentProps<"p">) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "section-description" },
props: mergeProps<"p">(
{
className: cn(
"w-full min-w-0 text-base/6 text-balance text-muted-foreground lg:text-lg/7",
className
),
},
props
),
})
}
// Stacked in a SectionHeader, the actions sit 24px under the text: the
// header's 16px gap plus 8px of their own.
const sectionActionsVariants = cva(
"flex max-w-full flex-wrap items-center gap-4 group-data-[variant=stack]/section-header:mt-2",
{
variants: {
/** `start` (the default) or `center`. */
align: {
start: "",
center: "justify-center",
},
},
defaultVariants: { align: "start" },
}
)
/**
* The band's buttons or links, in a row that wraps, 16px apart. Put it
* last in a SectionHeader, or anywhere else in the band.
*/
function SectionActions({
className,
align = "start",
...props
}: ComponentProps<"div"> & VariantProps<typeof sectionActionsVariants>) {
return (
<div
data-slot="section-actions"
data-align={align}
className={cn(sectionActionsVariants({ align }), className)}
{...props}
/>
)
}
/**
* A rounded panel inside a Section's column: edge to edge and square on a
* phone, then rounded with 96px of padding from `md`. Give it a theme
* class, such as `dark`, to paint it apart from the page.
*/
function SectionPanel({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-panel"
className={cn(
"relative isolate -mx-4 overflow-hidden border border-transparent bg-background px-4 py-12 text-foreground sm:-mx-6 sm:px-6 md:mx-0 md:rounded-lg md:p-24 dark:border-border",
className
)}
{...props}
/>
)
}
export {
Section,
SectionBackground,
SectionPanel,
SectionContent,
SectionColumns,
SectionHeader,
SectionTitle,
SectionDescription,
SectionActions,
sectionTitleVariants,
}
Installation
npx shadcn@latest add @01orbital/glass-icon-feature-gridMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/features/glass-icon-feature-grid/index.tsx: change them there, not in the markup. FEATURES, also at the top of the file, holds its lists and settings.- Its look comes from Panel Scene; each page lists the props that change it.
Built from
npm: @phosphor-icons/react. The CLI installs it for you.
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
Last updated on