Ai Suggestions
smoothui-registry/ai-suggestionsFreeComponent
Prompt suggestion chips that radiate in from the centre of the row rather than sweeping left to right.
Install it
npx shadcn@latest add https://www.smoothui.dev/r/ai-suggestions.jsonSource
1"use client";23import { cn } from "@/lib/utils";4import { AnimatePresence, motion, useReducedMotion } from "motion/react";5import { useMemo } from "react";67const SPRING_DEFAULT = {8 bounce: 0.1,9 duration: 0.25,10 type: "spring" as const,11};12const STAGGER_SECONDS = 0.045;1314export type AISuggestion = {15 id: string;16 label: string;17};1819export type AISuggestionsProps = {20 className?: string;21 /** Optional heading, e.g. "Follow-ups". */22 label?: string;23 onSelect?: (suggestion: AISuggestion) => void;24 suggestions: AISuggestion[];25};2627/**28 * Distance from the middle of the row, so the stagger radiates outwards from the29 * centre instead of sweeping left to right.30 *31 * A left-to-right sweep implies reading order and priority — that the first chip32 * matters most. These are alternatives of equal weight, and radiating from the33 * centre says so.34 */35const centreOutOrder = (count: number): number[] => {36 const middle = (count - 1) / 2;37 return Array.from({ length: count }, (_, index) => Math.abs(index - middle));38};3940/**41 * Prompt suggestion chips.42 *43 * Chips are the empty state of a chat and the follow-up row after an answer, so44 * they need to arrive without feeling like a notification.45 */46const AISuggestions = ({47 className,48 label,49 onSelect,50 suggestions,51}: AISuggestionsProps) => {52 const shouldReduceMotion = useReducedMotion();53 const delays = useMemo(54 () => centreOutOrder(suggestions.length),55 [suggestions.length]56 );5758 return (59 <div className={cn("flex w-full flex-col gap-2", className)}>60 {label ? (61 <p className="text-muted-foreground text-xs uppercase tracking-wide">62 {label}63 </p>64 ) : null}6566 <ul className="flex list-none flex-wrap gap-2">67 <AnimatePresence initial>68 {suggestions.map((suggestion, index) => (69 <motion.li70 animate={{ opacity: 1, scale: 1, y: 0 }}71 exit={72 shouldReduceMotion73 ? { opacity: 0, transition: { duration: 0 } }74 : { opacity: 0, scale: 0.94 }75 }76 initial={77 shouldReduceMotion78 ? { opacity: 1, scale: 1, y: 0 }79 : { opacity: 0, scale: 0.94, y: 6 }80 }81 key={suggestion.id}82 layout={!shouldReduceMotion}83 transition={84 shouldReduceMotion85 ? { duration: 0 }86 : {87// … truncated
What it pulls in
npm packages
Files it writes
More from SmoothUI Registry
All 178 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Agent Avataragent-avatar | SmoothUI Registry | Components | Free | no deps | |
| Ai Approvalai-approval | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Artifactai-artifact | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Branchai-branch | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Citationai-citation | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Context Meterai-context-meter | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Conversationai-conversation | SmoothUI Registry | Components | Free | 2 deps | |
| Ai Coreai-core | SmoothUI Registry | Components | Free | 1 dep |
