Guide Grid
Guide grid component: a grid whose rule lines are part of the design, with columns and rows per breakpoint, cells placed on lines or spans, solid cells that cover the guides, dashed guides, crosses at the intersections and a square option. For feature breakdowns and landing pages; Grid is the plain one.
import type { ComponentProps, CSSProperties } from "react"
import { cn } from "cn"
// A grid whose rule lines are part of the design, after Geist's Grid: the
// guides are a layer of empty cells under the content, each drawing its left
// and top edge, so a cell that spans or paints its own ground covers the
// lines without breaking them. Counts and placements step at the screen
// breakpoints, written out as literal classes so Tailwind can find them.
type Breakpoint = "base" | "sm" | "md" | "lg"
/** A value for every width, or one per breakpoint (`base` is the phone). */
type Steps<T> = T | Partial<Record<Breakpoint, T>>
/** A grid line (`3`) or a span between two lines (`"1/3"`). */
type Line = number | `${number}/${number}`
const MAX_COUNT = 12
const MAX_LINE = 13
const COLS = {
base: [
"",
"[--guide-cols:1]",
"[--guide-cols:2]",
"[--guide-cols:3]",
"[--guide-cols:4]",
"[--guide-cols:5]",
"[--guide-cols:6]",
"[--guide-cols:7]",
"[--guide-cols:8]",
"[--guide-cols:9]",
"[--guide-cols:10]",
"[--guide-cols:11]",
"[--guide-cols:12]",
],
sm: [
"",
"sm:[--guide-cols:1]",
"sm:[--guide-cols:2]",
"sm:[--guide-cols:3]",
"sm:[--guide-cols:4]",
"sm:[--guide-cols:5]",
"sm:[--guide-cols:6]",
"sm:[--guide-cols:7]",
"sm:[--guide-cols:8]",
"sm:[--guide-cols:9]",
"sm:[--guide-cols:10]",
"sm:[--guide-cols:11]",
"sm:[--guide-cols:12]",
],
md: [
"",
"md:[--guide-cols:1]",
"md:[--guide-cols:2]",
"md:[--guide-cols:3]",
"md:[--guide-cols:4]",
"md:[--guide-cols:5]",
"md:[--guide-cols:6]",
"md:[--guide-cols:7]",
"md:[--guide-cols:8]",
"md:[--guide-cols:9]",
"md:[--guide-cols:10]",
"md:[--guide-cols:11]",
"md:[--guide-cols:12]",
],
lg: [
"",
"lg:[--guide-cols:1]",
"lg:[--guide-cols:2]",
"lg:[--guide-cols:3]",
"lg:[--guide-cols:4]",
"lg:[--guide-cols:5]",
"lg:[--guide-cols:6]",
"lg:[--guide-cols:7]",
"lg:[--guide-cols:8]",
"lg:[--guide-cols:9]",
"lg:[--guide-cols:10]",
"lg:[--guide-cols:11]",
"lg:[--guide-cols:12]",
],
} as const
const ROWS = {
base: [
"",
"[--guide-rows:1]",
"[--guide-rows:2]",
"[--guide-rows:3]",
"[--guide-rows:4]",
"[--guide-rows:5]",
"[--guide-rows:6]",
"[--guide-rows:7]",
"[--guide-rows:8]",
"[--guide-rows:9]",
"[--guide-rows:10]",
"[--guide-rows:11]",
"[--guide-rows:12]",
],
sm: [
"",
"sm:[--guide-rows:1]",
"sm:[--guide-rows:2]",
"sm:[--guide-rows:3]",
"sm:[--guide-rows:4]",
"sm:[--guide-rows:5]",
"sm:[--guide-rows:6]",
"sm:[--guide-rows:7]",
"sm:[--guide-rows:8]",
"sm:[--guide-rows:9]",
"sm:[--guide-rows:10]",
"sm:[--guide-rows:11]",
"sm:[--guide-rows:12]",
],
md: [
"",
"md:[--guide-rows:1]",
"md:[--guide-rows:2]",
"md:[--guide-rows:3]",
"md:[--guide-rows:4]",
"md:[--guide-rows:5]",
"md:[--guide-rows:6]",
"md:[--guide-rows:7]",
"md:[--guide-rows:8]",
"md:[--guide-rows:9]",
"md:[--guide-rows:10]",
"md:[--guide-rows:11]",
"md:[--guide-rows:12]",
],
lg: [
"",
"lg:[--guide-rows:1]",
"lg:[--guide-rows:2]",
"lg:[--guide-rows:3]",
"lg:[--guide-rows:4]",
"lg:[--guide-rows:5]",
"lg:[--guide-rows:6]",
"lg:[--guide-rows:7]",
"lg:[--guide-rows:8]",
"lg:[--guide-rows:9]",
"lg:[--guide-rows:10]",
"lg:[--guide-rows:11]",
"lg:[--guide-rows:12]",
],
} as const
const COL_START = {
base: [
"",
"col-start-1",
"col-start-2",
"col-start-3",
"col-start-4",
"col-start-5",
"col-start-6",
"col-start-7",
"col-start-8",
"col-start-9",
"col-start-10",
"col-start-11",
"col-start-12",
"col-start-13",
],
sm: [
"",
"sm:col-start-1",
"sm:col-start-2",
"sm:col-start-3",
"sm:col-start-4",
"sm:col-start-5",
"sm:col-start-6",
"sm:col-start-7",
"sm:col-start-8",
"sm:col-start-9",
"sm:col-start-10",
"sm:col-start-11",
"sm:col-start-12",
"sm:col-start-13",
],
md: [
"",
"md:col-start-1",
"md:col-start-2",
"md:col-start-3",
"md:col-start-4",
"md:col-start-5",
"md:col-start-6",
"md:col-start-7",
"md:col-start-8",
"md:col-start-9",
"md:col-start-10",
"md:col-start-11",
"md:col-start-12",
"md:col-start-13",
],
lg: [
"",
"lg:col-start-1",
"lg:col-start-2",
"lg:col-start-3",
"lg:col-start-4",
"lg:col-start-5",
"lg:col-start-6",
"lg:col-start-7",
"lg:col-start-8",
"lg:col-start-9",
"lg:col-start-10",
"lg:col-start-11",
"lg:col-start-12",
"lg:col-start-13",
],
} as const
const COL_END = {
base: [
"",
"col-end-1",
"col-end-2",
"col-end-3",
"col-end-4",
"col-end-5",
"col-end-6",
"col-end-7",
"col-end-8",
"col-end-9",
"col-end-10",
"col-end-11",
"col-end-12",
"col-end-13",
],
sm: [
"",
"sm:col-end-1",
"sm:col-end-2",
"sm:col-end-3",
"sm:col-end-4",
"sm:col-end-5",
"sm:col-end-6",
"sm:col-end-7",
"sm:col-end-8",
"sm:col-end-9",
"sm:col-end-10",
"sm:col-end-11",
"sm:col-end-12",
"sm:col-end-13",
],
md: [
"",
"md:col-end-1",
"md:col-end-2",
"md:col-end-3",
"md:col-end-4",
"md:col-end-5",
"md:col-end-6",
"md:col-end-7",
"md:col-end-8",
"md:col-end-9",
"md:col-end-10",
"md:col-end-11",
"md:col-end-12",
"md:col-end-13",
],
lg: [
"",
"lg:col-end-1",
"lg:col-end-2",
"lg:col-end-3",
"lg:col-end-4",
"lg:col-end-5",
"lg:col-end-6",
"lg:col-end-7",
"lg:col-end-8",
"lg:col-end-9",
"lg:col-end-10",
"lg:col-end-11",
"lg:col-end-12",
"lg:col-end-13",
],
} as const
const ROW_START = {
base: [
"",
"row-start-1",
"row-start-2",
"row-start-3",
"row-start-4",
"row-start-5",
"row-start-6",
"row-start-7",
"row-start-8",
"row-start-9",
"row-start-10",
"row-start-11",
"row-start-12",
"row-start-13",
],
sm: [
"",
"sm:row-start-1",
"sm:row-start-2",
"sm:row-start-3",
"sm:row-start-4",
"sm:row-start-5",
"sm:row-start-6",
"sm:row-start-7",
"sm:row-start-8",
"sm:row-start-9",
"sm:row-start-10",
"sm:row-start-11",
"sm:row-start-12",
"sm:row-start-13",
],
md: [
"",
"md:row-start-1",
"md:row-start-2",
"md:row-start-3",
"md:row-start-4",
"md:row-start-5",
"md:row-start-6",
"md:row-start-7",
"md:row-start-8",
"md:row-start-9",
"md:row-start-10",
"md:row-start-11",
"md:row-start-12",
"md:row-start-13",
],
lg: [
"",
"lg:row-start-1",
"lg:row-start-2",
"lg:row-start-3",
"lg:row-start-4",
"lg:row-start-5",
"lg:row-start-6",
"lg:row-start-7",
"lg:row-start-8",
"lg:row-start-9",
"lg:row-start-10",
"lg:row-start-11",
"lg:row-start-12",
"lg:row-start-13",
],
} as const
const ROW_END = {
base: [
"",
"row-end-1",
"row-end-2",
"row-end-3",
"row-end-4",
"row-end-5",
"row-end-6",
"row-end-7",
"row-end-8",
"row-end-9",
"row-end-10",
"row-end-11",
"row-end-12",
"row-end-13",
],
sm: [
"",
"sm:row-end-1",
"sm:row-end-2",
"sm:row-end-3",
"sm:row-end-4",
"sm:row-end-5",
"sm:row-end-6",
"sm:row-end-7",
"sm:row-end-8",
"sm:row-end-9",
"sm:row-end-10",
"sm:row-end-11",
"sm:row-end-12",
"sm:row-end-13",
],
md: [
"",
"md:row-end-1",
"md:row-end-2",
"md:row-end-3",
"md:row-end-4",
"md:row-end-5",
"md:row-end-6",
"md:row-end-7",
"md:row-end-8",
"md:row-end-9",
"md:row-end-10",
"md:row-end-11",
"md:row-end-12",
"md:row-end-13",
],
lg: [
"",
"lg:row-end-1",
"lg:row-end-2",
"lg:row-end-3",
"lg:row-end-4",
"lg:row-end-5",
"lg:row-end-6",
"lg:row-end-7",
"lg:row-end-8",
"lg:row-end-9",
"lg:row-end-10",
"lg:row-end-11",
"lg:row-end-12",
"lg:row-end-13",
],
} as const
type ClassTable = Record<Breakpoint, readonly string[]>
const BREAKPOINTS: Breakpoint[] = ["base", "sm", "md", "lg"]
// One class per breakpoint the value names; a bare value is the base.
function stepClasses<T>(
value: Steps<T> | undefined,
pick: (bp: Breakpoint, v: T) => string
) {
if (value === undefined) return ""
if (typeof value !== "object") return pick("base", value)
return BREAKPOINTS.map((bp) => {
const v = (value as Partial<Record<Breakpoint, T>>)[bp]
return v === undefined ? "" : pick(bp, v)
}).join(" ")
}
const countClass = (table: ClassTable) => (bp: Breakpoint, n: number) =>
table[bp][Math.min(Math.max(Math.round(n), 1), MAX_COUNT)] ?? ""
// A plain line at a breakpoint also resets the end line, so a span set at a
// smaller width does not carry over.
const lineClasses =
(start: ClassTable, end: ClassTable, endAuto: Record<Breakpoint, string>) =>
(bp: Breakpoint, line: Line) => {
const [from, to] = String(line).split("/").map(Number)
const clamp = (n: number) => Math.min(Math.max(Math.round(n), 1), MAX_LINE)
const classes = [start[bp][clamp(from)]]
classes.push(to ? end[bp][clamp(to)] : endAuto[bp])
return classes.join(" ")
}
const COL_END_AUTO: Record<Breakpoint, string> = {
base: "col-end-auto",
sm: "sm:col-end-auto",
md: "md:col-end-auto",
lg: "lg:col-end-auto",
}
const ROW_END_AUTO: Record<Breakpoint, string> = {
base: "row-end-auto",
sm: "sm:row-end-auto",
md: "md:row-end-auto",
lg: "lg:row-end-auto",
}
// The most cells any breakpoint asks for: how many guide cells to draw.
function maxOf(value: Steps<number>) {
if (typeof value !== "object") return value
return Math.max(1, ...Object.values(value).filter((v) => v !== undefined))
}
type GuideGridProps = ComponentProps<"div"> & {
/** How many columns, for every width or per breakpoint (1 to 12). */
columns?: Steps<number>
/** How many rows, for every width or per breakpoint (1 to 12). */
rows: Steps<number>
/**
* Which rule lines to draw between cells: `both` (the default), only the
* lines between `rows`, only the lines between `columns`, or `none`.
*/
guides?: "both" | "rows" | "columns" | "none"
/** Draw the guides dashed. */
dashed?: boolean
/** Mark the grid's four corners with a small cross; `GuideGridCross` places others. */
cross?: boolean
/** Keep every cell square: the grid's height follows its width. */
square?: boolean
/**
* The grid's outer lines: `rows` (the default) above and below, `all`
* on every side, `none`. Use this rather than a border class, so the
* crosses land on the lines.
*/
frame?: "rows" | "all" | "none"
}
/**
* A grid whose rule lines are part of the design, for feature breakdowns
* and landing pages where the lines and cells are the composition. Put a
* `GuideGridCell` inside for each cell. For a plain card grid without
* visible lines, use `Grid`.
*
* `columns` and `rows` take a number, or one per breakpoint such as
* `{ base: 1, md: 2, lg: 3 }`; cells reflow between them. The guides sit in
* a layer under the cells in the border color, so a spanning or `solid`
* cell covers them. `guides` picks which lines to draw, `dashed` dashes
* them, `cross` marks the four corners, and `square` keeps the cells
* square. `frame` draws the outer lines: above and below by default, or on
* every side. The guides are hidden from assistive technology.
*/
function GuideGrid({
columns = 1,
rows,
guides = "both",
dashed = false,
cross = false,
square = false,
frame = "rows",
className,
children,
...props
}: GuideGridProps) {
const cells = maxOf(columns) * maxOf(rows)
return (
<div
data-slot="guide-grid"
data-guides={guides}
data-frame={frame}
className={cn(
"relative grid grid-cols-[repeat(var(--guide-cols),minmax(0,1fr))] grid-rows-[repeat(var(--guide-rows),minmax(0,1fr))]",
stepClasses(columns, countClass(COLS)),
stepClasses(rows, countClass(ROWS)),
square && "aspect-[var(--guide-cols)/var(--guide-rows)]",
className
)}
{...props}
>
{frame !== "none" && (
<div
aria-hidden="true"
className={cn(
"pointer-events-none absolute inset-0 border-border",
frame === "rows" ? "border-y" : "border"
)}
/>
)}
{guides !== "none" && (
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 grid auto-rows-[0px] grid-cols-[repeat(var(--guide-cols),minmax(0,1fr))] grid-rows-[repeat(var(--guide-rows),minmax(0,1fr))] [clip-path:inset(1px_0_0_1px)]"
>
{Array.from({ length: cells }, (_, index) => (
<div
key={index}
className={cn(
"border-border",
guides !== "rows" && "border-l",
guides !== "columns" && "border-t",
dashed && "border-dashed"
)}
/>
))}
</div>
)}
{children}
{cross &&
CORNERS.map((corner) => (
<span key={corner} aria-hidden="true" className={cn(CROSS, corner)} />
))}
</div>
)
}
// A cross is two 1px arms, 21px long, centered on a grid line crossing. It
// is darker than the guides (Geist: 66% gray against 92%), so it reads as a
// mark and not as more line.
const CROSS =
"pointer-events-none absolute size-0 before:absolute before:-top-[10px] before:left-0 before:h-[21px] before:w-px before:bg-muted-foreground/60 after:absolute after:top-0 after:-left-[10px] after:h-px after:w-[21px] after:bg-muted-foreground/60"
// A line at the far edge sits one pixel inside the box, so the last crossing
// is at 100% minus a pixel, not at 100%.
const CORNERS = [
"top-0 left-0",
"top-0 left-[calc(100%-1px)]",
"top-[calc(100%-1px)] left-0",
"top-[calc(100%-1px)] left-[calc(100%-1px)]",
] as const
type GuideGridCrossProps = ComponentProps<"span"> & {
/** The column line to sit on, 1 being the grid's left edge. */
column: number
/** The row line to sit on, 1 being the grid's top edge. */
row: number
}
/**
* A small cross on one crossing of a `GuideGrid`'s lines, for marking a
* corner or a junction the layout wants the eye to find. `column` and `row`
* are line numbers, counted from 1 at the top left; the line after the last
* column or row is the grid's right or bottom edge. Place it inside the
* grid, after the cells. Decorative, hidden from assistive technology.
*/
function GuideGridCross({
column,
row,
className,
style,
...props
}: GuideGridCrossProps) {
return (
<span
data-slot="guide-grid-cross"
aria-hidden="true"
style={
{ "--col": column - 1, "--row": row - 1, ...style } as CSSProperties
}
className={cn(
CROSS,
"top-[min(calc(100%*var(--row)/var(--guide-rows)),calc(100%-1px))] left-[min(calc(100%*var(--col)/var(--guide-cols)),calc(100%-1px))]",
className
)}
{...props}
/>
)
}
type GuideGridCellProps = ComponentProps<"div"> & {
/** The column line to start at, or a span such as `"1/3"`, for every width or per breakpoint. */
column?: Steps<Line>
/** The row line to start at, or a span such as `"1/3"`, for every width or per breakpoint. */
row?: Steps<Line>
/** Paint the cell in the page color so the guides behind it disappear. */
solid?: boolean
}
/**
* One cell of a `GuideGrid`, padded 24px, 48px from the `md` breakpoint.
* Without `column` and `row` it takes the next free cell. `column` and
* `row` place it on a grid line (`3`) or across a span (`"1/3"`), for every
* width or per breakpoint. `solid` paints it in the page color so the
* guides behind it disappear.
*/
function GuideGridCell({
column,
row,
solid = false,
className,
...props
}: GuideGridCellProps) {
return (
<div
data-slot="guide-grid-cell"
data-solid={solid || undefined}
className={cn(
"relative min-w-0 p-6 md:p-12",
stepClasses(column, lineClasses(COL_START, COL_END, COL_END_AUTO)),
stepClasses(row, lineClasses(ROW_START, ROW_END, ROW_END_AUTO)),
// Leaves the top and left pixel unpainted, so the lines around the
// cell stay and only the lines it spans across disappear.
solid &&
"border-t border-l border-transparent bg-background bg-clip-padding",
className
)}
{...props}
/>
)
}
export {
GuideGrid,
GuideGridCell,
GuideGridCross,
type GuideGridProps,
type GuideGridCellProps,
type GuideGridCrossProps,
}
import {
GuideGrid,
GuideGridCell,
} from "@/components/grid/guide-grid"
import { Text } from "@/components/text/text"
import { Title } from "@/components/title/title"
// The copy: change text here, not in the markup.
const CELLS = [
{
title: "Blocks and scenes",
text: "Finished sections, and the art that sits behind them.",
},
{ title: "Orbs", text: "Painted spheres with their own light." },
{ title: "Textures", text: "Grain, linen and paper over any ground." },
{
title: "Templates and docs",
text: "Whole sites, and the pages that explain the parts.",
},
] as const
const ROW = ["Browse", "Install", "Customize", "Deploy"] as const
/**
* GuideGrid: a responsive grid with two solid spanning cells, then a single
* row with column guides only, crosses at the intersections.
*/
export default function GuideGridDemo() {
return (
<div className="grid w-full max-w-4xl gap-16">
<GuideGrid
columns={{ base: 1, md: 2, lg: 3 }}
rows={{ base: 6, md: 3, lg: 2 }}
>
<GuideGridCell
column={{ base: 1, md: "1/3" }}
row={{ base: "1/3", md: 1 }}
solid
className="flex flex-col justify-end gap-2"
>
<Title>{CELLS[0].title}</Title>
<Text variant="muted">{CELLS[0].text}</Text>
</GuideGridCell>
<GuideGridCell className="flex flex-col gap-2">
<Title>{CELLS[1].title}</Title>
<Text variant="muted">{CELLS[1].text}</Text>
</GuideGridCell>
<GuideGridCell className="flex flex-col gap-2">
<Title>{CELLS[2].title}</Title>
<Text variant="muted">{CELLS[2].text}</Text>
</GuideGridCell>
<GuideGridCell
column={{ base: 1, md: "1/3", lg: "2/4" }}
row={{ base: "5/7", md: 3, lg: 2 }}
solid
className="flex flex-col justify-end gap-2"
>
<Title>{CELLS[3].title}</Title>
<Text variant="muted">{CELLS[3].text}</Text>
</GuideGridCell>
</GuideGrid>
<GuideGrid
columns={{ base: 2, md: 4 }}
rows={{ base: 2, md: 1 }}
guides="columns"
cross
>
{ROW.map((step) => (
<GuideGridCell key={step} className="p-6 md:p-6">
<Text>{step}</Text>
</GuideGridCell>
))}
</GuideGrid>
</div>
)
}
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"
// The paragraph under a Heading or Subheading, in a hero or a section
// header. No width of its own: give it one with a `max-w-*` class when the
// layout wants it. Inherits the surrounding ink, so it reads over art;
// muted steps it down on a flat ground.
const textVariants = cva("w-full min-w-0 text-pretty", {
variants: {
/**
* The text color. `default` (the default) keeps the inherited color.
* `muted` uses `muted-foreground`.
*/
variant: {
default: "",
muted: "text-muted-foreground",
},
/**
* The text size: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines, the lead under a page headline.
*/
size: {
md: "text-base/7",
lg: "text-lg/8",
},
},
defaultVariants: { variant: "default", size: "md" },
})
/**
* The paragraph under a heading, a `p` by default. For several paragraphs,
* pass `render={<div />}` and put your own `p` elements inside.
*
* `size` sets the text: `md` (the default) 16px with 28px lines, `lg` 18px
* with 32px lines for the lead under a page headline. `variant="muted"`
* uses the muted text color; the default inherits the ink around it.
*/
function Text({
className,
variant = "default",
size = "md",
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size }), className) },
props
),
})
}
export { Text }
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cn } from "cn"
// No width of its own: the card, panel or column that holds it is the
// measure. text-pretty keeps a wrapped title from ending on one word.
/**
* The title of a card, panel or list group, rendered as an `<h3>` in the body
* font: 18px with a 28px line, 20px from the `sm` breakpoint, medium weight.
* One size, no props beyond the element's own; pass `render` to use another
* heading level. Inside a stock `Card`, use `CardTitle`; a section's heading
* is `Subheading` and a page's headline is `Heading`.
*/
function Title({
className,
render,
...props
}: useRender.ComponentProps<"h3">) {
return useRender({
defaultTagName: "h3",
render,
state: { slot: "title" },
props: mergeProps<"h3">(
{
className: cn(
"text-lg/7 font-medium tracking-tight text-pretty sm:text-xl/7",
className
),
},
props
),
})
}
export { Title }
Installation
pnpm dlx shadcn@latest add @01orbital/guide-gridnpx shadcn@latest add @01orbital/guide-gridyarn dlx shadcn@latest add @01orbital/guide-gridbunx --bun shadcn@latest add @01orbital/guide-gridUsage
import {
GuideGrid,
GuideGridCell,
} from "@/components/grid/guide-grid"
import { Text } from "@/components/text/text"
import { Title } from "@/components/title/title"
// The copy: change text here, not in the markup.
const CELLS = [
{
title: "Blocks and scenes",
text: "Finished sections, and the art that sits behind them.",
},
{ title: "Orbs", text: "Painted spheres with their own light." },
{ title: "Textures", text: "Grain, linen and paper over any ground." },
{
title: "Templates and docs",
text: "Whole sites, and the pages that explain the parts.",
},
] as const
const ROW = ["Browse", "Install", "Customize", "Deploy"] as const
/**
* GuideGrid: a responsive grid with two solid spanning cells, then a single
* row with column guides only, crosses at the intersections.
*/
export default function GuideGridDemo() {
return (
<div className="grid w-full max-w-4xl gap-16">
<GuideGrid
columns={{ base: 1, md: 2, lg: 3 }}
rows={{ base: 6, md: 3, lg: 2 }}
>
<GuideGridCell
column={{ base: 1, md: "1/3" }}
row={{ base: "1/3", md: 1 }}
solid
className="flex flex-col justify-end gap-2"
>
<Title>{CELLS[0].title}</Title>
<Text variant="muted">{CELLS[0].text}</Text>
</GuideGridCell>
<GuideGridCell className="flex flex-col gap-2">
<Title>{CELLS[1].title}</Title>
<Text variant="muted">{CELLS[1].text}</Text>
</GuideGridCell>
<GuideGridCell className="flex flex-col gap-2">
<Title>{CELLS[2].title}</Title>
<Text variant="muted">{CELLS[2].text}</Text>
</GuideGridCell>
<GuideGridCell
column={{ base: 1, md: "1/3", lg: "2/4" }}
row={{ base: "5/7", md: 3, lg: 2 }}
solid
className="flex flex-col justify-end gap-2"
>
<Title>{CELLS[3].title}</Title>
<Text variant="muted">{CELLS[3].text}</Text>
</GuideGridCell>
</GuideGrid>
<GuideGrid
columns={{ base: 2, md: 4 }}
rows={{ base: 2, md: 1 }}
guides="columns"
cross
>
{ROW.map((step) => (
<GuideGridCell key={step} className="p-6 md:p-6">
<Text>{step}</Text>
</GuideGridCell>
))}
</GuideGrid>
</div>
)
}This example installs with everything it uses:
pnpm dlx shadcn@latest add @01orbital/guide-grid-demonpx shadcn@latest add @01orbital/guide-grid-demoyarn dlx shadcn@latest add @01orbital/guide-grid-demobunx --bun shadcn@latest add @01orbital/guide-grid-demoAnatomy
Guide Grid is built from 3 parts. In the example they nest like this:
GuideGrid
└─ GuideGridCellGuideGrid: A grid whose rule lines are part of the design, for feature breakdowns and landing pages where the lines and cells are the composition. Put aGuideGridCellinside for each cell. For a plain card grid without visible lines, useGrid.GuideGridCell: One cell of aGuideGrid, padded 24px, 48px from themdbreakpoint. Withoutcolumnandrowit takes the next free cell.columnandrowplace it on a grid line (3) or across a span ("1/3"), for every width or per breakpoint.solidpaints it in the page color so the guides behind it disappear.GuideGridCross: A small cross on one crossing of aGuideGrid's lines, for marking a corner or a junction the layout wants the eye to find.columnandroware line numbers, counted from 1 at the top left; the line after the last column or row is the grid's right or bottom edge. Place it inside the grid, after the cells. Decorative, hidden from assistive technology.
API reference
GuideGrid
A grid whose rule lines are part of the design, for feature breakdowns and landing pages where the lines and cells are the composition. Put a GuideGridCell inside for each cell. For a plain card grid without visible lines, use Grid.
columns and rows take a number, or one per breakpoint such as { base: 1, md: 2, lg: 3 }; cells reflow between them. The guides sit in a layer under the cells in the border color, so a spanning or solid cell covers them. guides picks which lines to draw, dashed dashes them, cross marks the four corners, and square keeps the cells square. frame draws the outer lines: above and below by default, or on every side. The guides are hidden from assistive technology.
Prop
Type
It also accepts the HTML attributes of the element it renders.
GuideGridCell
One cell of a GuideGrid, padded 24px, 48px from the md breakpoint. Without column and row it takes the next free cell. column and row place it on a grid line (3) or across a span ("1/3"), for every width or per breakpoint. solid paints it in the page color so the guides behind it disappear.
Prop
Type
It also accepts the HTML attributes of the element it renders.
GuideGridCross
A small cross on one crossing of a GuideGrid's lines, for marking a corner or a junction the layout wants the eye to find. column and row are line numbers, counted from 1 at the top left; the line after the last column or row is the grid's right or bottom edge. Place it inside the grid, after the cells. Decorative, hidden from assistive technology.
Prop
Type
It also accepts the HTML attributes of the element it renders.
Dependencies
npm: cn. The CLI installs it for you.
Last updated on