{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tile-group",
  "type": "registry:ui",
  "title": "Tile Group",
  "description": "A grid of large tiles, each a picture or an icon with a word, where one or several are chosen.",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "lucide-react",
    "radix-ui"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/ui/tile-group.tsx",
      "type": "registry:ui",
      "target": "components/ui/tile-group.tsx",
      "content": "\"use client\";\n/**\n * @name tile-group\n * @category ui\n * @description A grid of large tiles, each a picture or an icon with a word, where one or several are chosen.\n * @when A choice that is easier to make by looking than by reading: moods, styles, room types, plans. Each tile must carry a visible word; the picture alone is never the label. For short text-only options use chip (ChipGroup); for a compact switch between a few views use segmented-control; for a long list use select or combobox.\n * @example\n * <TileGroup type=\"multiple\" defaultValue={[\"quiet\"]} aria-label=\"What kind of day?\">\n *   <Tile value=\"quiet\">\n *     <TileMedia><img src=\"/quiet.jpg\" alt=\"\" /></TileMedia>\n *     <TileLabel>Quiet</TileLabel>\n *     <TileDescription>Gardens, reading rooms, slow walks</TileDescription>\n *   </Tile>\n *   <Tile value=\"lively\">\n *     <TileMedia><img src=\"/lively.jpg\" alt=\"\" /></TileMedia>\n *     <TileLabel>Lively</TileLabel>\n *   </Tile>\n * </TileGroup>\n */\nimport { ToggleGroup as ToggleGroupPrimitive } from \"radix-ui\";\nimport { Check } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\nexport type TileGroupProps = ComponentProps<typeof ToggleGroupPrimitive.Root>;\n\n/**\n * `type=\"multiple\"` lets several tiles be on (each is a toggle button in a group); `type=\"single\"` lets one\n * be on (each is a radio in a radio group). Arrow keys move between tiles, Space or Enter switches one. The\n * tiles sit in a grid that follows the width of its container: two columns when narrow, more as it widens\n * (override with a `grid-cols-*` class). Name the group with `aria-label` or `aria-labelledby`. `value`,\n * `defaultValue` and `onValueChange` control it: a string for \"single\", an array for \"multiple\".\n */\nexport function TileGroup({ className, ...props }: TileGroupProps) {\n  // Radix calls a set of toggles a toolbar; a set of choices is a plain group.\n  const role = props.role ?? (props.type === \"multiple\" ? \"group\" : \"radiogroup\");\n  return (\n    <div data-slot=\"tile-group-container\" className=\"@container w-full\">\n      <ToggleGroupPrimitive.Root\n        data-slot=\"tile-group\"\n        className={cn(\"grid grid-cols-2 gap-3 @md:grid-cols-3 @2xl:grid-cols-4\", className)}\n        {...props}\n        role={role}\n      />\n    </div>\n  );\n}\n\nexport type TileProps = ComponentProps<typeof ToggleGroupPrimitive.Item>;\n\n/**\n * One tile. When on it takes a strong edge in the highlight colour and shows a tick in its corner, so the\n * state is not carried by colour alone. Pictures inside are decoration (`alt=\"\"`): the TileLabel names the tile.\n */\nexport function Tile({ className, children, ...props }: TileProps) {\n  return (\n    <ToggleGroupPrimitive.Item\n      data-slot=\"tile\"\n      className={cn(\n        \"group/tile relative flex min-w-0 flex-col overflow-hidden rounded-surface border border-border-strong bg-card text-start text-card-foreground transition-[background-color,border-color,opacity,scale] duration-instant ease-out select-none hover:bg-accent active:scale-[0.99] disabled:pointer-events-none disabled:opacity-50 data-[state=on]:border-primary data-[state=on]:bg-highlight-soft data-[state=on]:outline-1 data-[state=on]:-outline-offset-1 data-[state=on]:outline-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none motion-reduce:active:scale-100\",\n        className,\n      )}\n      {...props}\n    >\n      {children}\n      <span\n        aria-hidden=\"true\"\n        data-slot=\"tile-check\"\n        className=\"absolute end-2 top-2 hidden size-6 items-center justify-center rounded-full bg-primary text-primary-foreground group-data-[state=on]/tile:inline-flex\"\n      >\n        <Check strokeWidth={2} className=\"size-3.5\" />\n      </span>\n    </ToggleGroupPrimitive.Item>\n  );\n}\n\nexport type TileMediaProps = ComponentProps<\"span\"> & {\n  /** Width / height of the picture area. Default 4 / 3. The box keeps it, so nothing shifts while a picture loads. */\n  aspect?: number;\n};\n\n/** The picture or icon area. A picture fills and is cropped to it; an icon is centred on a muted ground. */\nexport function TileMedia({ className, aspect = 4 / 3, style, ...props }: TileMediaProps) {\n  return (\n    <span\n      data-slot=\"tile-media\"\n      className={cn(\n        \"flex w-full items-center justify-center overflow-hidden bg-muted text-muted-foreground [&>img]:size-full [&>img]:object-cover [&>svg]:size-8\",\n        className,\n      )}\n      style={{ aspectRatio: String(aspect), ...style }}\n      {...props}\n    />\n  );\n}\n\n/** The tile's word: its accessible name. */\nexport function TileLabel({ className, ...props }: ComponentProps<\"span\">) {\n  return <span data-slot=\"tile-label\" className={cn(\"px-3 pt-2.5 text-sm font-medium last:pb-2.5\", className)} {...props} />;\n}\n\n/** A line under the word. */\nexport function TileDescription({ className, ...props }: ComponentProps<\"span\">) {\n  return <span data-slot=\"tile-description\" className={cn(\"px-3 pt-0.5 pb-2.5 text-sm text-muted-foreground\", className)} {...props} />;\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "A choice that is easier to make by looking than by reading: moods, styles, room types, plans. Each tile must carry a visible word; the picture alone is never the label. For short text-only options use chip (ChipGroup); for a compact switch between a few views use segmented-control; for a long list use select or combobox.",
    "example": "<TileGroup type=\"multiple\" defaultValue={[\"quiet\"]} aria-label=\"What kind of day?\">\n  <Tile value=\"quiet\">\n    <TileMedia><img src=\"/quiet.jpg\" alt=\"\" /></TileMedia>\n    <TileLabel>Quiet</TileLabel>\n    <TileDescription>Gardens, reading rooms, slow walks</TileDescription>\n  </Tile>\n  <Tile value=\"lively\">\n    <TileMedia><img src=\"/lively.jpg\" alt=\"\" /></TileMedia>\n    <TileLabel>Lively</TileLabel>\n  </Tile>\n</TileGroup>",
    "client": true
  }
}
