compacto-ui

Search documentation

Jump to a page or a component.

OptionGrid

Standalone swatch cards for a choice that deserves a real preview.

Preview

Installation

No install — ask an AI agent to copy this component from registry.json.

import { OptionGrid } from "@/components/ui/option-grid";

Notes

  • The swatch is entirely the caller's ReactNode, sizing included — this component only owns card chrome, selection state and the Check badge.
  • Controlled only — value and onValueChange are both required.
  • Derives ${testId}-<value> per card from data-testid.
  • A card paints from the --app-* tokens in scope, so an option's style can repaint one card in a different palette — appThemeCssVars(theme) is how the theming page previews twenty-three palettes on a page rendered in one of them.

Props

The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.

PropTypeDefaultDescription
options{ value, label, description?, swatch: ReactNode, style? }[]—The choices, in order.
valuestring—The selected option's value.
onValueChange(value: string) => void—Called with a value when its tile is clicked.