use-idle
Utility hook for detecting user inactivity.
Installation
npx shadcn add @limeplay/use-idleUsage
import { useIdle } from "@/hooks/limeplay/use-idle"
function PlayerControls() {
const isIdle = useIdle({ timeout: 3000 })
return (
<div className={isIdle ? "opacity-0" : "opacity-100"}>
{/* Controls fade out when user is idle */}
</div>
)
}Options
| Option | Type | Default | Description |
|---|---|---|---|
timeout | number | 3000 | Milliseconds of inactivity before idle |
initialState | boolean | false | Initial idle state |
events | string[] | ["mousemove", "keydown", ...] | Events that reset the idle timer |
Returns true when the user has been inactive for longer than timeout.