Krizaka
Documentation

Card grid

A responsive grid of cards: as many columns as the width allows (one on a phone), the cells of a row at one height, a staggered reveal and the light that follows the pointer.

WebBêtaBlocs

Web uniquement — React, depuis @krizaka/ui/card-grid. Bêta : son API peut encore changer à une version mineure.

Quand l’utiliser

  • Entry points of a hub (LinkCard), the reasons of a product page (ArgumentCard), plans, products.
  • Any set of peer cards that should read as one group with one rhythm.

Quand ne pas l’utiliser

  • For a sequence the reader follows in order.À la place : Stepper
  • For rows of data to compare or sort.À la place : Data table

Installation

Installer

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Importer

import { CardGrid } from "@krizaka/ui/card-grid";

Exemples

Two halves

fit="fit": two cards share the whole width.

A list of sections

as="ul", six links that rise staggered by column on a real page.

Props

A responsive grid of cards: equal rows, a staggered reveal, the pointer's light.

PropTypeDéfautDescription
childrenrequisReactNode—The cards: one cell each.
align"stretch" | "start"stretchstretch gives the cells of a row one height; start lets each card keep its own (cards that open a panel).
as"div" | "ol" | "ul"divul when the cards are a list (each cell an li).
columnsnumber3The columns the stagger counts (the delay restarts on every row).
fit"fit" | "fill"fillfill keeps empty tracks (a lone card keeps its width); fit stretches the cards of a short row across the width.
lightbooleantrueThe light that follows the pointer over the cards ([data-kz-light]).
minnumber300The narrowest a column may be, in pixels: the grid fits as many columns as the width allows.
revealbooleantrueThe cards rise once into place ([data-reveal], MotionObserver), staggered by column. false on the first screen.

Accessibilité

  • The grid adds no role; as="ul" makes it a list (each cell an li).
  • The pointer's light is decorative and never runs on touch screens or under prefers-reduced-motion.
  • Revealed cells are only hidden visually until they enter the viewport; under reduced motion they never move.

Bonnes pratiques

  • Set min to the narrowest a card still reads well; the grid does the rest at every width.
  • fit="fit" for two or three cards that should share the whole width; fill keeps a lone card at its size.
  • Keep reveal on below the first screen, off on it; columns makes the stagger restart on each row.
  • as="ul" when the cards are a list of links.

Générée depuis le code de @krizaka/ui 2.8.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page