Skip to Content
NarakUI

Video Player

Play video from any source. The player comes styled, and you can replace or recompose every part of it.

Default player

This player uses the default skin with a title, a description, and chapters. Hover the timeline to see the chapter under the pointer, and open the settings menu to change quality, speed, captions, or Picture-in-Picture. To play audio in a single control bar, use the Audio Player.

Demo video

Hover the timeline to inspect chapters or open settings.

0:00

How the pieces fit together

A player has three required parts: the player, the skin, and the media. Each part has one job and nests inside the part above it, so you can change one without touching the others.

import { Title, Video, VideoPlayer, VideoSkin } from '@/components/ui/video-player';

<VideoPlayer title="Demo video" poster={posterUrl}>
  <VideoSkin className="aspect-video w-full">
    <Video src={videoUrl} playsInline />
    <Title description="Optional subtitle line." />
  </VideoSkin>
</VideoPlayer>;
PartComponentWhat it owns
PlayerVideoPlayerPlayback state for everything inside it. Takes title and poster, renders no UI.
SkinVideoSkinThe interface: control bar, poster, loading and error states, shortcuts, gestures.
MediaVideo, YouTubeVideo, HlsJsVideo, MuxVideoThe source. Renders the media element (or YouTube IFrame bridge) and nothing else.
TracksChaptersTrackExtra data for the media. Render it as a child of the media.
AdditionsTitle, TimedSlot, UpNext, UserPreferencesOptional overlays and behavior. Render them inside the skin.

Any component inside the player can read playback state with usePlayer, even outside the skin:

import { selectTime, usePlayer } from '@/components/ui/video-player';

const currentTime = usePlayer((state) => selectTime(state)?.currentTime);

Responsive layout

The control bar responds to the width of the player (@container/player), not the page, so the same player works in a sidebar and in fullscreen. Drag the slider to see it: the captions button drops first, then the time labels, so the timeline keeps its room.

Demo video

Drag the slider to resize the player.

0:00

Show video details

Poster

The poster is the image the player shows before playback. Set poster on VideoPlayer, not on the media, to use your own image. Pass renderPoster to VideoSkin to render a custom image component such as next/image.

0:00

Title and description

Set title on VideoPlayer, then render Title inside VideoSkin to show it. Title takes an optional description for a second line, which hides on players narrower than 448px.

Demo video

A second line under the title.

0:00

Pass visibility="fullscreen" when the page already shows the title next to the player and the overlay should appear only in fullscreen.

0:00

Chapters

Chapters split the timeline into segments and name the segment under the pointer. Render ChaptersTrack as a child of the media, with start times in seconds from the start of the video.

0:00

Internationalization

Pass locale to VideoSkin to translate labels, menus, and screen reader announcements, and automatically mirror right-to-left (RTL) locales such as Arabic (ar).

فيديو تجريبي

اختر لغة، ثم مرّر المؤشر فوق أحد الأزرار أو افتح قائمة الإعدادات.

0:00

Remember viewer preferences

Render UserPreferences inside VideoSkin to persist the viewer's volume, mute, speed, and captions in localStorage under player:preferences. Change a setting, then press Next video to mount a fresh player.

Video 1

Change the volume, speed, or captions, then load the next video.

0:00

Saved preferences: none yet

Timed overlays and Up next

TimedSlot renders its children over the video during a [start, end] range (negative values count back from the end). Bottom slots lift automatically while the control bar is visible. UpNext builds on TimedSlot to present the next item before playback finishes.

Video 1

A badge and skip button show between 0:05 and 0:35. Up next appears 10 seconds before the end.

0:00

Keyboard shortcuts and gestures

Shortcuts are active while focus is inside the player so multiple players on one page never compete for keys.

KeysAction
Space, KPlay or pause
← →, J LSeek 10 seconds
↑ ↓Change the volume
MMute
0–9Jump to 0% through 90%
Home, EndJump to the start or the end
<, >Play slower or faster
CToggle captions
FToggle fullscreen
IToggle Picture-in-Picture

Click plays or pauses; double-click seeks 10 seconds in the left or right third and toggles fullscreen in the center third.

Player states

Loading

Use Skeleton sized to the same aspect-video container while a player mounts.

Buffering

When playback waits for data for more than 500ms, the buffering indicator appears automatically.

0:00

Error

When the source cannot play, the skin shows a short message and disables controls.

0:00

Build your own control bar

Not recommended

The default control bar keeps every player in the product consistent. Replace it only when a surface cannot use it, such as a compact preview.

Compose PlayButton, TimeSlider, FullscreenButton, and other exported controls into a custom bar and pass it to VideoSkin via controls. Pass controls={null} to remove the bar completely.

Installation

pnpm dlx shadcn@latest add @narakui/video-player

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/video-player.json.

Reference

VideoPlayer

PropTypeDescription
titlestring | nullThe title of the video
posterstring | nullThe image shown before playback. Replaces any poster the media generates

VideoSkin

PropTypeDefaultDescription
classNamestring—Sizes the player, for example aspect-video w-full
controlsReactNode | null<DefaultVideoControls />Replaces the default control bar. null removes it
localestringPage languageLanguage of labels, tooltips, and RTL direction
renderPoster(props, state) => ReactNode—Custom renderer for the poster image

Title

PropTypeDescription
descriptionReactNodeSecond line under the title (hidden below 448px)
visibility'inline' | 'fullscreen'Restricts the title overlay to inline or fullscreen mode
classNamestringAdditional classes for the title overlay

ChaptersTrack

PropTypeDescription
chapters{ startTime: number; title: string }[]Required. Start times in seconds from the start of the media

TimedSlot

PropTypeDefaultDescription
startnumber0Start time in seconds (negative counts back from end)
endnumberVideo endEnd time in seconds (negative counts back from end)
openbooleantrueHides the slot inside its range when false
placement'bottom-end' | 'bottom-start' | 'top-end' | 'top-start''bottom-end'Corner placement inside the player
transitionIn'slide' | 'fade' | 'scale' | 'none''slide'Entrance transition style
transitionOut'slide' | 'fade' | 'scale' | 'none'Same as transitionInExit transition style

UpNext

PropTypeDefaultDescription
titleReactNode—Title of the next video
descriptionReactNode—Short description (hidden below 512px)
labelReactNodeTranslated “Up next”Eyebrow label above the title
thumbnailSrcstring—Preview thumbnail or animated GIF (hidden below 448px)
hrefstring—Makes the card a link instead of a button
secondsnumber10Seconds before the end when the card appears
onSelect() => void—Called when the viewer clicks the card
onComplete() => void—Called when the media ends unless dismissed