Limeplay - Open Source Video Player UI ComponentsLimeplay

use-controls-visibility

Utility hook for auto-hiding player controls.

Installation

npx shadcn add @limeplay/use-controls-visibility

Requires mediaFeature and playbackFeature registered in your createMediaKit.

Feature Registration

use-controls-visibility is a utility hook, not a media feature. Register the store features it reads before using it inside a player tree:

lib/media.ts
"use client"

import { mediaFeature } from "@/hooks/limeplay/use-media"
import { playbackFeature } from "@/hooks/limeplay/use-playback"
import { createMediaKit } from "@/components/limeplay/media-provider"

createMediaKit({
  features: [mediaFeature(), playbackFeature()] as const,
})

Store

useControlsVisibility does not create its own store slice. It reads state from mediaFeature and playbackFeature, then returns root props and a class name for the caller to apply.

State

FieldOwnerDescription
debugmediaFeatureKeeps controls visible while debug mode is enabled.
forceIdlemediaFeaturePrevents the hook from changing idle state when forced.
idlemediaFeatureDrives whether controls and cursor can hide.
statusplaybackFeatureKeeps controls visible while buffering, paused, or errored.

Actions

MethodOwnerDescription
setIdle(value)mediaFeatureUpdates idle state after interaction timers.

Usage

import {
  CONTROLS_FORCE_VISIBLE_ATTRIBUTE,
  useControlsVisibility,
} from "@/hooks/limeplay/use-controls-visibility"

export function PlayerShell() {
  const controlsVisibility = useControlsVisibility()

  return (
    <div
      {...controlsVisibility.rootProps}
      className={controlsVisibility.className}
    >
      <video />

      <div {...{ [CONTROLS_FORCE_VISIBLE_ATTRIBUTE]: "" }}>
        <button>Play</button>
      </div>
    </div>
  )
}

rootProps should be spread on the player root. Add CONTROLS_FORCE_VISIBLE_ATTRIBUTE to any controls area that should keep controls visible while hovered or scrubbed.

Events

useControlsVisibility does not emit custom media events.

EventEmitted byDescription
NoneuseControlsVisibilityThe hook only handles DOM events.

The returned rootProps attach pointer and focus handlers to update mediaFeature idle state.

DOM eventWhen it is handled
blurHides controls after focus leaves the root
focusShows controls while focus is inside
pointerenterShows controls and may schedule auto-hide
pointerleaveHides controls
pointermoveShows controls and may schedule auto-hide
pointeroverKeeps controls visible over forced areas
pointerupShows controls and may schedule auto-hide

API Reference

Prop

Type

On this page