Grid

@sushindustries/ui

A responsive grid with no breakpoints in it. One number decides the column count at every width.

5 min read
View as MarkdownEdit on GitHub

Four cards that become one column, without a media query anywhere.

Viewport width
Phone22remthe floor, the narrowest this promises to work at
tanstacktanstack add https://adamjurek.com/r/tanstack/grid.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/grid.json

The whole mechanism

grid-template-columns: repeat(auto-fit, minmax(var(--grid-min), 1fr));
css

min is the narrowest a column may get. Columns fit as many as will fit at that width and share what is left, so the same grid is four across on a desktop and one across at 320 and nobody wrote either number down.

Why not a media query

Not brevity. A media query asks about the viewport, and a grid three levels inside a sidebar does not care about the viewport - it cares about the width it was given. auto-fit asks the right question, so the same component behaves correctly in a place its author never saw.

That is also why this reflows correctly inside the Showcase at 320 without the Showcase knowing anything about it.

Where this is used

WhereWhat for
Any .md on this sitethe ::start:grid block
packages/ui/docs/nav-bar/index.mdthe two-up explanation of wide and narrow
.nav-panel-listthe same auto-fit rule, inlined, so the nav has no dependency on this

Install

tanstack add https://adamjurek.com/r/tanstack/grid.json
shell
pnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/grid.json
shell
pnpm add @sushindustries/ui @sushindustries/atoms
shell

What you get

Version0.1.0
Categorylayout · Page structure
Filesgrid.tsx
DependenciesNone
Also installsspacerSpacerVertical space on the scale, optionally with a rule and a label. For Markdown, where there is no markup to hang a margin on.@sushindustries/ui · layout
Tagsgrid, responsive, no-deps

No runtime dependencies

It brings nothing with it beyond the stylesheet.