Skip to Content

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.

Installation

pnpm dlx shadcn@latest add @01orbital/guide-grid

Usage

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-demo

Anatomy

Guide Grid is built from 3 parts. In the example they nest like this:

GuideGrid
└─ GuideGridCell
  • 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.
  • 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.
  • 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.

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