UI.MD

Video Controls

A floating pill of controls over a video or animation player: play, a seek bar, the time and the speaker. It shows when the pointer moves and hides after two idle seconds.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/video-controls.json

Usage

import { VideoControls } from "@/components/ui/video-controls"

Examples

Default

Put the controls in the same positioned box as the video. A mouse click on the video plays or pauses it; on touch, the first tap only shows the controls.

0:00
0:00

API Reference

PropTypeDefaultDescription
media*RefObject<HTMLVideoElement> | VideoControlsMedia-A ref to a <video>, or an adapter for any other player. The video must render together with the controls.
showSoundbooleantrueShows the speaker. Pass false for a clip with no sound.
hotkeysbooleanfalseSpace plays and pauses and M mutes, from anywhere on the page. Only for a player that owns the page, such as a lightbox.
onMutedChange(muted: boolean) => void-Called after the speaker or M changes the sound, to remember the choice.
media*RefObject<HTMLVideoElement> | VideoControlsMediaA ref to a <video>, or an adapter for any other player. The video must render together with the controls.
showSoundboolean = trueShows the speaker. Pass false for a clip with no sound.
hotkeysboolean = falseSpace plays and pauses and M mutes, from anywhere on the page. Only for a player that owns the page, such as a lightbox.
onMutedChange(muted: boolean) => voidCalled after the speaker or M changes the sound, to remember the choice.