gooey-ai
brainframe-ui-registry/gooey-aiFreeComponent
A gooey AI prompt component with an expandable dialog, controlled textarea, and customizable trigger.
Install it
npx shadcn@latest add https://www.brainframeui.tech/r/gooey-ai.jsonSource
1"use client";23import { cn } from "@/lib/utils";4import { ArrowUp, PlusIcon, Square } from "lucide-react";5import { easeOut, motion } from "motion/react";6import {7 createContext,8 ReactNode,9 useContext,10 useEffect,11 useRef,12 useState,13} from "react";1415type GooeyAIContextType = {16 value: string;17 setValue: React.Dispatch<React.SetStateAction<string>>;18 isLoading: boolean;19 onSubmit: () => void;2021 isExpanded: boolean;22 setIsExpanded: React.Dispatch<React.SetStateAction<boolean>>;2324 rootRef: React.RefObject<HTMLDivElement | null>;25};2627const GooeyAIContext = createContext<GooeyAIContextType | null>(null);28function useGooeyAI() {29 const context = useContext(GooeyAIContext);3031 if (!context) {32 throw new Error("GooeyAI components must be inside <GooeyAI>");33 }3435 return context;36}3738type GooeyAIProps = {39 children: ReactNode;40 value: string;41 setValue: React.Dispatch<React.SetStateAction<string>>;42 isLoading: boolean;43 onSubmit: () => void;44};4546export function GooeyAI({47 children,48 value,49 setValue,50 isLoading,51 onSubmit,52}: GooeyAIProps) {53 const [isExpanded, setIsExpanded] = useState(false);5455 const rootRef = useRef<HTMLDivElement>(null);5657 useEffect(() => {58 if (!isExpanded) return;5960 function handleOutsideClick(e: MouseEvent) {61 if (rootRef.current?.contains(e.target as Node)) return;62 setIsExpanded(false);63 }6465 document.addEventListener("pointerdown", handleOutsideClick);6667 return () =>68 document.removeEventListener("pointerdown", handleOutsideClick);69 }, [isExpanded]);7071 return (72 <GooeyAIContext.Provider73 value={{74 value,75 setValue,76 isLoading,77 onSubmit,78 isExpanded,79 setIsExpanded,80 rootRef,81 }}82 >83 <div84 style={{85 filter: "url(#gooey-AI)",86 }}87 className="flex flex-col justify-center space-y-2"88 >89 <GooeyFilter />9091 <div92 ref={rootRef}93 className="relative w-14 h-14 flex items-center justify-center"94 >95 {children}96 </div>97 </div>98 </GooeyAIContext.Provider>99 );100}101102export function GooeyAIButton({ className }: { className?: string }) {103 const { isExpanded, setIsExpanded } = useGooeyAI();104105 return (106 <button107 onClick={() => setIsExpanded(!isExpanded)}108 className={cn(109// … truncated
What it pulls in
npm packages
Files it writes
More from Brainframe UI Registry
All 2 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| prompt-inputprompt-input | Brainframe UI Registry | Components | Free | 1 dep |
