Prompt Suggestion
prompt-kit-agents-ui/prompt-suggestionFreeComponent
A component for implementing interactive prompt suggestions in AI interfaces. The PromptSuggestion component offers two distinct modes: Normal Mode and Highlight Mode.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/agents-ui/agents-kit/main/public/c/prompt-suggestion.jsonSource
1"use client"23import { Button, buttonVariants } from "@/components/ui/button"4import { cn } from "@/lib/utils"5import { VariantProps } from "class-variance-authority"67export type PromptSuggestionProps = {8 children: React.ReactNode9 variant?: VariantProps<typeof buttonVariants>["variant"]10 size?: VariantProps<typeof buttonVariants>["size"]11 className?: string12 highlight?: string13} & React.ButtonHTMLAttributes<HTMLButtonElement>1415function PromptSuggestion({16 children,17 variant,18 size,19 className,20 highlight,21 ...props22}: PromptSuggestionProps) {23 const isHighlightMode = highlight !== undefined && highlight.trim() !== ""24 const content = typeof children === "string" ? children : ""2526 if (!isHighlightMode) {27 return (28 <Button29 variant={variant || "outline"}30 size={size || "lg"}31 className={cn("rounded-full", className)}32 {...props}33 >34 {children}35 </Button>36 )37 }3839 if (!content) {40 return (41 <Button42 variant={variant || "ghost"}43 size={size || "sm"}44 className={cn(45 "w-full cursor-pointer justify-start rounded-xl py-2",46 "hover:bg-accent",47 className48 )}49 {...props}50 >51 {children}52 </Button>53 )54 }5556 const trimmedHighlight = highlight.trim()57 const contentLower = content.toLowerCase()58 const highlightLower = trimmedHighlight.toLowerCase()59 const shouldHighlight = contentLower.includes(highlightLower)6061 return (62 <Button63 variant={variant || "ghost"}64 size={size || "sm"}65 className={cn(66 "w-full cursor-pointer justify-start gap-0 rounded-xl py-2",67 "hover:bg-accent",68 className69 )}70 {...props}71 >72 {shouldHighlight ? (73 (() => {74 const index = contentLower.indexOf(highlightLower)75 if (index === -1)76 return (77 <span className="text-muted-foreground whitespace-pre-wrap">78 {content}79 </span>80 )8182 const actualHighlightedText = content.substring(83 index,84 index + highlightLower.length85 )8687 const before = content.substring(0, index)88 const after = content.substring(index + actualHighlightedText.length)8990 return (91 <>92 {before && (93 <span className="text-muted-foreground whitespace-pre-wrap">94 {before}95 </span>96// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from prompt-kit
All 12 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Chat Containerchat-container | prompt-kit | Components | Free | 1 dep | |
| Code Blockcode-block | prompt-kit | Components | Free | 1 dep | |
| File Uploadfile-upload | prompt-kit | Components | Free | no deps | |
| Jsx Previewjsx-preview | prompt-kit | Components | Free | 1 dep | |
| Loaderloader | prompt-kit | Components | Free | no deps | |
| Markdownmarkdown | prompt-kit | Components | Free | 4 deps · 2 files | |
| Messagemessage | prompt-kit | Components | Free | 5 deps · 3 files | |
| Prompt Inputprompt-input | prompt-kit | Components | Free | no deps |
