Skip to content

VariantGrid

Stable

A set of made options where you pick one, with empty slots held for ones still coming.

Also known as variations grid, results grid, image grid

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Four options, one picked

Each option has a name for screen readers. Tab to the picked tile, then use the arrow keys, Home and End.

When to use it

Shows options the assistant made as square tiles and lets people pick one. Empty slots hold space for options still on the way, so tiles do not jump around.

Made of: Option tile · AI label · Check mark · Loading placeholder

Use it for

  • Picking one of several generated images or designs.
  • A round of options that arrive one by one: set loadingCount.
  • Comparing options side by side before opening one in a canvas.

Not for

  • Picking several options at once.
  • Media that people look at but do not choose between: use MediaGrid.
  • Buttons to vary, upscale or remix one option: use VariationActions.

Do and avoid

Do. The whole tile is the choice, and the pick has a check mark.
Avoid. Buttons inside each tile crowd it and hide what picking means.

Do

  • Give each option its own name.
  • Hold space for options that are still arriving.
  • Make the content fill the square tile.
  • Mark made images with the AI label. VariantTile adds it for you.
  • Update selectedId in onSelect, since arrow keys pick as they move.

Avoid

  • Do not use it to pick several. It allows one choice.
  • Do not put buttons inside a tile. The whole tile is the button.
  • Do not rely on border color alone to show the pick. The check mark covers it.

On a phone

  • Tiles show in two columns on a phone and in four columns from 600px wide, and each tile stays square.
  • Tiles are tapped to select, and the selected tile shows a check mark, so selection does not depend on hover.
  • Loading slots are the same square size, so the grid does not jump when the options arrive.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started