Limeplay - Open Source Video Player UI ComponentsLimeplay

use-idle

Utility hook for detecting user inactivity.

Installation

npx shadcn add @limeplay/use-idle

Usage

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

OptionTypeDefaultDescription
timeoutnumber3000Milliseconds of inactivity before idle
initialStatebooleanfalseInitial idle state
eventsstring[]["mousemove", "keydown", ...]Events that reset the idle timer

Returns true when the user has been inactive for longer than timeout.

On this page