flowui
componentdebounced-inputsource: ok · hit
Debounced Input
An input component with optional debouncing support.
npx shadcn add "https://flowui-registry.vercel.app/r/debounced-input.json"free
No selection tags yet — empty means no evidence, not lack of support.
Dependencies
Bundle weight · lightRegistry dependencies
input
Files1 · source cached 10/14/2026, 2:19:56 PM
registry/flowui/components/debounced-input.tsx
"use client";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
import { useEffect, useState } from "react";
type DebouncedInputProps = {
debouncing?: boolean;
debouncingValue?: number;
onDebouncedChange?: (value: string) => void;
className?: string;
} & React.ComponentProps<typeof Input>;
const DebouncedInput = ({ debouncing, debouncingValue = 500, onDebouncedChange, className, ...props }: DebouncedInputProps) => {
const isControlled = props.value !== undefined;
// This is used so that user typing is not affected by the debouncing
const [input, setInput] = useState(
isControlled ?
(props.value as string) :
(props.defaultValue as string) ?? ""
);
useEffect(() => {
if (isControlled) {
setInput(props.value as string);
}
}, [props.value, isControlled]);
useEffect(() => {
if (!debouncing) return;
// Set timer
const timer = setTimeout(() => {
onDebouncedChange?.(input);
}, debouncingValue);
// Clear timeout
return () => clearTimeout(timer);
}, [input, debouncing, debouncingValue]);
return (
<Input
{...props}
value={isControlled ? props.value : input}
onChange={(e) => {
if (!isControlled) {
setInput(e.target.value);
}
props.onChange?.(e);
}}
className={cn(className)}
/>
)
}
export default DebouncedInput;