Skip to content
Klarhimmel UI

Grid card

npx shadcn add https://ui.klarhimmel.com/r/grid-card.json

Examples

  • Grid

  • Tiles

DetailsAbout, usage, props and more

One card for every grid of things: a square picture, icon or thumbnail, a title and a meta line. Rows share a height; on a phone each card is a row. For files and folders, look="tile" in a CardGrid size small or large: frameless tiles, three or two on a phone.

Preview

  • The bakery page

    Spring menu

    New photos and prices for the Saturday bakes.

    4 tasks · 1 needs your OKIn progress
  • The café page

    Garden café opening

    Opening hours, the terrace and a short note for the local paper, ready before the first warm weekend of May.

    Done 3 OctDone
  • Colours, type and voice.

    PDF · 12 pages
grid-card.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { GridCard, CardGrid, CardGridItem } from '@/components/klarhimmel/ui/grid-card';

export default function Example() {
  return (
    <Theme theme="brand">
      <CardGrid label="Projects"><CardGridItem><GridCard href="/projects/menu" title="Spring menu" description="New photos and prices." meta="4 tasks" media={{ image: { src: '/menu.jpg', alt: 'The menu page' } }} /></CardGridItem></CardGrid>
    </Theme>
  );
}

Import

Import

import { GridCard, CardGrid, CardGridItem, GridCardSquare } from '@/components/klarhimmel/ui/grid-card';
Files
grid-card.tsx, in components/klarhimmel/ui/. With it: badge, theme, utils. npm: lucide-react.
Render in
Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.

Props

PropTypeDefaultDescription
GridCard.titleReactNoderequiredOne or two lines; the card's link (or button) text.
GridCard.descriptionReactNode-A sentence or two under the title, clamped to three lines.
GridCard.metaReactNode-One quiet line pinned to the foot of the card: a kind, a date, a count.
GridCard.mediaGridCardMedia-The square at the top (beside the text on a narrow grid). Omitted: text only.
GridCard.badgeReactNode-A string becomes a neutral Badge over the media; pass a Badge for another tone.
GridCard.pillReactNode-A short label floating over the picture's top left, such as a date. Shown only with media.
GridCard.look'card' | 'tile''card'card: framed, a row beside its square below
GridCard.hrefstring-Where the card goes. Give `href` or `onClick`, not both.
GridCard.onClick() => void-For a card that opens something in place (a side panel, a sheet).
GridCard.link(props: { href: string; className: string; children: ReactNode }) => ReactNodeplainLinkRenders the title link, for a router's Link. Default: a plain <a>.
GridCard.classNamestring-Extra classes, merged after the component's own.
CardGrid.childrenReactNoderequired
CardGrid.labelstring-
CardGrid.sizekeyof typeof GRID'default'
CardGrid.classNamestring-Extra classes, merged after the component's own.
CardGridItem.childrenReactNoderequired
GridCardSquare.mediaGridCardMediarequiredThe square: a picture (cover), a centred icon, any node such as a mockup thumbnail, or a folder: up to 4 of its pictures as a mosaic (the folder icon when it has none; count belongs in meta).