For Tailwind CSS v3 docs, click here.

Infinite Grid

A high-performance, interactive 3D infinite grid component built with OGL as seen on phantom.land

API

Prop NameTypeDefaultDescription
cardDataCardData[][]Data for every tile shown in the grid. Required.
optionsPartial<InfiniteGridOptions>{}Optional overrides for layout, camera, and post-processing (see table below).

InfiniteGridOptions

OptionTypeDefaultDescription
gridColsnumber4Grid Columns .
gridRowsnumber4Grid Rows .
gridGapnumber0Gap between squares.
tileSizenumber2.4Tile size (OGL units).
baseCameraZnumber10Starting Z-distance of the camera.
enablePostProcessingbooleantrueToggle the post-processing pipeline.
postProcessParams.distortionIntensitynumber-0.2Barrel / pincushion distortion strength (0 = none).
postProcessParams.vignetteOffsetnumber0.0Vignette offset; higher ⇒ smaller clear area.
postProcessParams.vignetteDarknessnumber0.0Vignette darkness; higher ⇒ darker edges.

CardData

FieldTypeRequiredDescription
titlestringMain heading text.
badgestringBadge label (render logic can be customised).
descriptionstringLonger body text.
tagsstring[]Tag pills rendered at the bottom.
datestringDate string shown bottom-right.
imagestringURL for the tile's background image.

Emits

Event NamePayloadDescription
tileClicked{ card: CardData, index: number }Fired whenever a tile is clicked/tapped. The payload contains the clicked CardData object and its zero-based index.
onTileLoaded-Fired when all the images are loaded inside the tile.

Install using CLI

npm
pnpm
bun
yarn
npx shadcn-vue@latest add "https://registry.inspira-ui.com/infinite-grid.json"

Install Manually

Install the dependencies

npm
pnpm
bun
yarn
npm install ogl gsap

Copy and paste the following code in the same folder

InfiniteGrid.vue
InfiniteGridClass.ts
DisposalManager.ts
EventHandler.ts
GridManager.ts
PostProcessShader.ts
createTexture.ts
shaders.ts
types.ts

Credits

  • Inspired from Phantom Land
  • Special thanks to Safak Dinc for the idea and for granting permission to include it here. You can find the original repository at infinite-grid. Your contribution is greatly appreciated!
  • Credits to kalix127 for porting this component.