Here's a custom useDebounceSearch hook that debounces the search input and returns the debounced value along with loading state:
import { useEffect, useState } from "react";
export function useDebounceSearch(value: string, delay = 300) {
const [debouncedValue, setDebouncedValue] = useState(value);
const [isDebouncing, setIsDebouncing] = useState(false);
useEffect(() => {
setIsDebouncing(true);
const timer = setTimeout(() => {
setDebouncedValue(value);
setIsDebouncing(false);
}, delay);
return () => clearTimeout(timer);
}, [value, delay]);
return { debouncedValue, isDebouncing };
}Here's an example search component using the hook:
import { useState } from "react";
import { useDebounceSearch } from "./use-debounce-search";
export function SearchInput() {
const [query, setQuery] = useState("");
const { debouncedValue, isDebouncing } = useDebounceSearch(query);
useEffect(() => {
if (!debouncedValue) return;
fetch("/api/search?q=" + debouncedValue)
.then((res) => res.json())
.then(setResults);
}, [debouncedValue]);
return (
<div>
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search..."
/>
{isDebouncing && <span>Searching...</span>}
</div>
);
}Developer-focused chat interface with syntax-highlighted code blocks, language badges, copy-to-clipboard buttons, and file name tabs. Optimized for code generation and programming assistance.
chat12
Chat message thread with rich formatting, copy and thumbs-up/down action buttons on AI messages, and time-grouped message sections. Features hover-revealed action bars and smooth animations.
chat11
Full-featured chatbot window with message thread, AI and user avatars, timestamp display, typing indicator, and rich input area with send button. Suitable as the primary chat experience.
chat16
Chat interface featuring multiple AI agents with distinct personas, colored avatars, and role badges. Each agent has a unique personality and expertise area, creating a panel discussion experience.
chat15
Chat interface with image attachment previews, file upload indicators, and image gallery display within messages. Supports both user-uploaded images and AI-generated image responses.