{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "suggestion-chips",
  "title": "Suggestion chips",
  "description": "Starter prompts that stagger in on springs, lift on hover and fill the composer on click, as pills, cards with hints or a scrolling row with faded edges; swapping the set replays the entrance.",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/ai/suggestion-chips.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { ArrowUpRight } from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, spring } from \"@/lib/goodui-motion\"\n\n/*\n * Prompt suggestions for an empty chat: chips (or cards) that stagger in, lift on hover and hand their prompt\n * to the composer on click. Swapping the list replays the stagger; a selected chip can clear the rest.\n */\n\nexport type Suggestion =\n  | string\n  | {\n      label: string\n      /** Text sent to the composer; defaults to the label. */\n      prompt?: string\n      icon?: React.ReactNode\n      /** Second line in the card variant. */\n      hint?: string\n    }\n\nexport type SuggestionChipsLabels = { suggestions: string }\nconst DEFAULT_LABELS: SuggestionChipsLabels = { suggestions: \"Suggested prompts\" }\n\nexport type SuggestionChipsProps = Omit<React.ComponentProps<\"div\">, \"onSelect\"> & {\n  suggestions: Suggestion[]\n  onSelect?: (prompt: string, suggestion: Exclude<Suggestion, string>) => void\n  /** chip: pills in a wrapping row. card: icon, label and hint in a grid. scroll: one horizontal row that scrolls. */\n  variant?: \"chip\" | \"card\" | \"scroll\"\n  /** Seconds between each chip's entrance. */\n  stagger?: number\n  /** Hide the other chips once one is picked. */\n  clearOnSelect?: boolean\n  /** Change it to replay the entrance. */\n  playKey?: React.Key\n  /** Text for screen readers; pass translations here. */\n  labels?: Partial<SuggestionChipsLabels>\n}\n\nconst norm = (s: Suggestion) => (typeof s === \"string\" ? { label: s } : s)\n\n/** Staggered prompt suggestions that fill the composer. */\nexport function SuggestionChips({ suggestions, onSelect, variant = \"chip\", stagger = 0.05, clearOnSelect = false, playKey, labels, className, ...props }: SuggestionChipsProps) {\n  const l = useLabels(\"suggestion-chips\", DEFAULT_LABELS, labels)\n  const reduce = useReducedMotion() ?? false\n  const [picked, setPicked] = React.useState<string | null>(null)\n  const items = React.useMemo(() => suggestions.map(norm), [suggestions])\n  React.useEffect(() => setPicked(null), [suggestions, playKey])\n\n  const shown = clearOnSelect && picked !== null ? items.filter((s) => s.label === picked) : items\n  const card = variant === \"card\"\n\n  return (\n    <div\n      role=\"group\"\n      aria-label={l.suggestions}\n      className={cn(\n        \"pc-suggestions\",\n        variant === \"chip\" && \"flex flex-wrap gap-2\",\n        card && \"grid gap-2 sm:grid-cols-2\",\n        variant === \"scroll\" && \"flex gap-2 overflow-x-auto px-1 py-1 [-ms-overflow-style:none] [scrollbar-width:none] [mask-image:linear-gradient(90deg,transparent,#000_12px,#000_calc(100%-12px),transparent)] [&::-webkit-scrollbar]:hidden\",\n        className,\n      )}\n      {...props}\n    >\n      <GooduiTokens />\n      <AnimatePresence initial mode=\"popLayout\">\n        {shown.map((s, i) => (\n          <motion.button\n            key={`${String(playKey ?? \"\")}-${s.label}`}\n            type=\"button\"\n            layout\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: 10, scale: 0.96 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={reduce ? { opacity: 0, transition: { duration: 0.1 } } : { opacity: 0, scale: 0.9, transition: { duration: 0.15 } }}\n            transition={reduce ? { duration: 0 } : { ...spring.ui, delay: Math.min(i, 12) * stagger }}\n            whileHover={reduce ? undefined : { y: -2 }}\n            whileTap={reduce ? undefined : { scale: 0.97 }}\n            onClick={() => {\n              setPicked(s.label)\n              onSelect?.(s.prompt ?? s.label, s)\n            }}\n            className={cn(\n              \"group/chip cursor-pointer border bg-card text-start text-card-foreground outline-none transition-[border-color,box-shadow,background-color] hover:border-foreground/30 hover:bg-muted/60 hover:shadow-[var(--pc-e1)] focus-visible:ring-3 focus-visible:ring-ring/50\",\n              card ? \"flex flex-col gap-1.5 rounded-xl p-3\" : \"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full ps-3 pe-2.5 text-sm whitespace-nowrap\",\n              picked === s.label && \"border-foreground/40 bg-muted\",\n            )}\n          >\n            {card ? (\n              <>\n                <span className=\"flex items-center gap-2\">\n                  {s.icon && <span className=\"grid size-7 place-items-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4\">{s.icon}</span>}\n                  <span className=\"text-sm font-medium\">{s.label}</span>\n                  <ArrowUpRight className=\"ms-auto size-4 text-muted-foreground opacity-0 transition-[opacity,transform] group-hover/chip:opacity-100 group-focus-visible/chip:opacity-100 rtl:-scale-x-100\" aria-hidden=\"true\" />\n                </span>\n                {s.hint && <span className=\"text-xs leading-5 text-muted-foreground\">{s.hint}</span>}\n              </>\n            ) : (\n              <>\n                {s.icon && <span className=\"text-muted-foreground [&_svg]:size-4\">{s.icon}</span>}\n                <span>{s.label}</span>\n                <ArrowUpRight className=\"size-3.5 text-muted-foreground transition-transform group-hover/chip:translate-x-0.5 group-hover/chip:-translate-y-0.5 rtl:-scale-x-100 rtl:group-hover/chip:-translate-x-0.5\" aria-hidden=\"true\" />\n              </>\n            )}\n          </motion.button>\n        ))}\n      </AnimatePresence>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/suggestion-chips.tsx"
    }
  ],
  "categories": [
    "components",
    "ai"
  ],
  "type": "registry:component"
}