Tile

A marketing box for showcase, specimen and feature grids: art on top, a title and a muted line below. Its corner, padding, gap, shadow and ring follow the shadcn style through the box tokens.

Installation

npx shadcn@latest add @01orbital/tile

Usage

import { MoonSphere } from "@/components/orbs/moon-sphere"
import { DemoLabel } from "@/components/text/demo-label"
import { Grain } from "@/components/texture/grain"
import {
  Tile,
  TileDescription,
  TileHeader,
  TileMedia,
  TileTitle,
} from "@/components/tile/tile"

const COPY = {
  title: "Waxing gibbous",
  description: "Most of the face lit, rising in the late afternoon.",
  captions: {
    media: "With TileMedia: art above the title",
    text: "Title and description only",
    grain: "With a texture inside, on a toned ground: Grain fills the box",
  },
} as const

/** Tile three ways: with art, text only, and with a texture inside. */
export default function TileDemo() {
  return (
    <div className="grid w-full max-w-4xl gap-x-4 gap-y-10 sm:grid-cols-3">
      <div className="grid content-start gap-4">
        <Tile>
          <TileMedia>
            <MoonSphere size={96} />
          </TileMedia>
          <TileHeader>
            <TileTitle>{COPY.title}</TileTitle>
            <TileDescription>{COPY.description}</TileDescription>
          </TileHeader>
        </Tile>
        <DemoLabel>{COPY.captions.media}</DemoLabel>
      </div>
      <div className="grid content-start gap-4">
        <Tile>
          <TileHeader>
            <TileTitle>{COPY.title}</TileTitle>
            <TileDescription>{COPY.description}</TileDescription>
          </TileHeader>
        </Tile>
        <DemoLabel>{COPY.captions.text}</DemoLabel>
      </div>
      <div className="grid content-start gap-4">
        {/* Overlay grain vanishes on white, so this tile has a toned ground. */}
        <Tile className="bg-[oklch(0.78_0.04_70)] text-[oklch(0.25_0.02_70)] [--muted-foreground:oklch(0.35_0.02_70)]">
          <Grain opacity={0.6} />
          <TileMedia>
            <MoonSphere size={96} />
          </TileMedia>
          <TileHeader>
            <TileTitle>{COPY.title}</TileTitle>
            <TileDescription>{COPY.description}</TileDescription>
          </TileHeader>
        </Tile>
        <DemoLabel>{COPY.captions.grain}</DemoLabel>
      </div>
    </div>
  )
}

This example installs with everything it uses:

npx shadcn@latest add @01orbital/tile-demo

Anatomy

Tile is built from 5 parts. In the example they nest like this:

Tile
├─ TileMedia
└─ TileHeader
   ├─ TileTitle
   └─ TileDescription
  • Tile: A marketing box: one item in a showcase, specimen or feature grid, with art on top and a title and line below. It is plain markup, not a Card (a Card holds app content). Its corner, padding, gap, shadow and ring read the box tokens, so it takes the look of whichever shadcn style the page uses.
  • TileMedia: The art at the top of a tile: an orb, an image or an icon.
  • TileHeader: Holds the title and description, 8px apart.
  • TileTitle: The tile's name, an <h3> at 18px medium weight.
  • TileDescription: One or two lines under the title, in the muted color.

API reference

Tile

A marketing box: one item in a showcase, specimen or feature grid, with art on top and a title and line below. It is plain markup, not a Card (a Card holds app content). Its corner, padding, gap, shadow and ring read the box tokens, so it takes the look of whichever shadcn style the page uses.

Compose it from TileMedia, TileHeader, TileTitle and TileDescription. A texture such as SimpleGrain can go first inside it: it fills the box, and the parts stay above it.

It accepts the HTML attributes of the element it renders.

TileMedia

The art at the top of a tile: an orb, an image or an icon.

It accepts the HTML attributes of the element it renders.

TileHeader

Holds the title and description, 8px apart.

It accepts the HTML attributes of the element it renders.

TileTitle

The tile's name, an <h3> at 18px medium weight.

It accepts the HTML attributes of the element it renders.

TileDescription

One or two lines under the title, in the muted color.

It accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Used in blocks

One block is built with Tile.

Last updated on