Components

Every part in react-video-kit, with its props.

These are the styled parts. Each is built on one with the same name in react-video-kit/primitives, which has no skin. To see how they fit together, read Styled parts.

Plugin parts, such as Fullscreen and CaptionsMenu, are listed on each plugin's page.

All of this page comes from the package's types, so it's always up to date.

Components

AsChild

Renders the single child with a part's behaviour, instead of the part's element.

BufferingIndicator
Button

A control button. data-control is what the skin styles.

PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
ControlGroup

A pill of related controls.

ControlRow
Controls

Holds the controls. Stays mounted while hidden, so Tab can reveal it.

CurrentTime

Current position. Writes to the DOM directly, so playback causes no renders.

Duration
ErrorOverlay

Explains a fatal error in the viewer's language, with a code to quote to support, in place of an endless spinner. It offers a retry unless the error rules that out.

PropTypeDescription
title?stringReplaces the title, whatever the error.
messages?Partial<Record<VideoErrorCode, ErrorMessage>>Replaces the text for particular error codes.
Media

The media element. The active provider owns its source, so this renders no src or <source> children. Pass <track> elements as children.

Menu

A menu that renders inside the player, so it keeps working in fullscreen. Submenus drill down in place rather than opening beside it.

PropTypeDescription
children?ReactNodeThe menu's trigger and content.
onOpenChange?((open: boolean) => void)Called as the menu opens and closes.
MenuContent
PropTypeDescription
children?ReactNodeThe rows at the top level of the menu.
MenuItem
PropTypeDescription
disabled?booleanStops the item being chosen or reached with the keyboard.
onSelect?(() => void)Runs when chosen. The menu closes afterwards unless keepOpen is set.
keepOpen?booleanLeaves the menu open after the item is chosen.
MenuRadioGroup
PropTypeDescription
valuestring | nullThe value of the checked item, or null when none is checked.
onValueChange(value: string) => voidCalled with an item's value when the viewer chooses it.
MenuRadioItem
PropTypeDescription
valuestringIdentifies this item to the group, and is what onValueChange receives.
MenuSub

A row that drills down to a panel of its own.

PropTypeDescription
titleReactNodeThe row's name, which also titles the submenu.
value?ReactNodeThe current value, shown at the end of the row. A value that changes during playback should be a component that reads it, so that nothing renders until the menu is open.
icon?ReactNodeShown before the title.
backLabel?stringLabels the back button.
MenuTrigger
PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
Mute
PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayOverlay
PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayPause

Icons stack in one grid cell, so the skin can cross-fade between states.

PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayerContext
RemainingTime

Time left, written to the DOM directly like CurrentTime.

Root

The player root with the default skin. Import react-video-kit/styles.css for it.

PropTypeDescription
src?SourceInput | nullThe video to play, which loads afresh when its value changes.
plugins?readonly AnyPlugin[]Set once. Define the array outside the component or memoize it.
load?LoadStrategyWhen the provider and its engine load. Set once. Defaults to eager.
player?PlayerBring your own player instead of creating one.
onError?((error: MediaErrorInfo) => void)Called with every error, fatal or not, for logging. It can change between renders.
children?ReactNodeContent rendered inside the player's root element.
SeekButton
PropTypeDescription
secondsnumberSeconds to move. Negative goes back.
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
SettingsMenu

A menu of whatever plugins contribute to the menu slot. Hidden when empty.

PropTypeDescription
children?ReactNodeThe rows at the top level of the menu.
Slot

Renders what plugins contributed to name, in plugin order.

PropTypeDescription
nameSlotNameThe slot to render, such as overlay or menu.
Time

Current time and duration together.

Timeline

The seek bar. A real range input provides focus, keyboard, and screen reader support, while the visible track takes pointer input over a larger hit area.

PropTypeDescription
step?numberSeconds moved by the arrow keys.
largeStep?numberSeconds moved by Page Up and Page Down.
children?ReactNodeReplaces the default track, thumb, and preview.
TimelineBuffered
TimelineFill
TimelinePreview

Follows the pointer with the time under it, staying inside the track.

PropTypeDescription
children?ReactNodeShown above the time, such as a thumbnail.
TimelineThumb

The rail spans the track and moves as a whole, so percentages need no measuring.

TimelineTrack
Title

The video's name, with an optional line above it and a description below.

PropTypeDescription
title?ReactNodeThe video's name.
eyebrow?ReactNodeA short line above the title, such as a series or an episode.
description?ReactNodeA sentence or two about the video, which shows while it's paused.
Transport

The buttons in the centre of the picture: seek back, play, and seek forward.

PropTypeDescription
seekSeconds?numberHow far the buttons on either side of play jump, in seconds.
Volume

Mute button and slider, with the slider opening as the pointer arrives.

VolumeSlider

Renders nothing where the platform owns volume, such as iOS.

PropTypeDescription
step?numberChange per arrow key press, from 0 to 1.

Icons

AirPlayIcon
CaptionsIcon
CastIcon
FullscreenEnterIcon
FullscreenExitIcon
NextIcon
PauseIcon
PipEnterIcon
PipExitIcon
PlayIcon
PreviousIcon
ReplayIcon
SeekIcon

A ring with an arrowhead, turning back or forward, and the seconds in the middle.

PropTypeDescription
secondsnumberThe seconds shown in the ring, with a negative number turning the arrow back.
SettingsIcon
SpinnerIcon

Eight ticks, fading around the circle. The skin turns it one tick at a time.

VolumeIcon

The speaker. The skin reads --rv-volume from the mute button, so each wave fades with the level, and the slash falls across the speaker when it's muted.

Hooks

useClock

Runs write as playback advances, without rendering. Use this for anything that follows time: fills, thumbs, and text written straight to the DOM.

(write: (time: number) => void, resolution: () => number) => void
useCommands

Core commands, or a plugin's commands when given its factory.

{ (): CoreCommands; <Factory extends AnyPluginFactory>(plugin: Factory): CommandsOf<Factory>; }
useCurrentTime

Time as React state, for text. Renders once per resolution seconds.

(resolution?: number) => number
useLabel

A localized string from the i18n plugin when it's installed, else fallback.

(key: string, fallback: string) => string
usePlayer
() => Player
useTimelinePreview

Calls listener with the time under the pointer, or null when there is none.

(listener: PreviewListener) => void
useVideoState

Subscribes to a plugin's state, typed from the plugin factory. Subscribes to kernel media state, re-rendering only when the result changes.

{ <Factory extends AnyPluginFactory, Value>(plugin: Factory, select: (state: StateOf<Factory>, media: MediaState) => Value, isEqual?: Equality<Value>): Value; <Value>(select: (media: MediaState) => Value, isEqual?: Equality<Value>): Value; }

Functions

mergeRefs

Forwards a node to several refs.

<Value>(...refs: (Ref<Value> | undefined)[]) => (node: Value | null) => void
shallow

Compares one level deep, for selectors that build arrays or objects.

<Value>(a: Value, b: Value) => boolean

Types

BufferingIndicatorProps
BufferingIndicatorProps
ButtonProps
FieldTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
ControlGroupProps
ControlGroupProps
ControlRowProps
ControlRowProps
ControlsProps
ControlsProps
CurrentTimeProps
TimeProps
DurationProps
TimeProps
ErrorMessage
FieldTypeDescription
title?stringReplaces the title.
detail?stringReplaces the line under the title.
ErrorOverlayProps
FieldTypeDescription
title?stringReplaces the title, whatever the error.
messages?Partial<Record<VideoErrorCode, ErrorMessage>>Replaces the text for particular error codes.
IconProps
IconProps
MediaProps
MediaProps
MenuContentProps
FieldTypeDescription
children?ReactNodeThe rows at the top level of the menu.
MenuItemProps
FieldTypeDescription
disabled?booleanStops the item being chosen or reached with the keyboard.
onSelect?(() => void)Runs when chosen. The menu closes afterwards unless keepOpen is set.
keepOpen?booleanLeaves the menu open after the item is chosen.
MenuProps
FieldTypeDescription
children?ReactNodeThe menu's trigger and content.
onOpenChange?((open: boolean) => void)Called as the menu opens and closes.
MenuRadioGroupProps
FieldTypeDescription
valuestring | nullThe value of the checked item, or null when none is checked.
onValueChange(value: string) => voidCalled with an item's value when the viewer chooses it.
MenuRadioItemProps
FieldTypeDescription
valuestringIdentifies this item to the group, and is what onValueChange receives.
MenuSubProps
FieldTypeDescription
titleReactNodeThe row's name, which also titles the submenu.
value?ReactNodeThe current value, shown at the end of the row. A value that changes during playback should be a component that reads it, so that nothing renders until the menu is open.
icon?ReactNodeShown before the title.
backLabel?stringLabels the back button.
MenuTriggerProps
FieldTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
MuteProps
FieldTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayOverlayProps
FieldTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayPauseProps
FieldTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
RemainingTimeProps
TimeProps
RootProps
FieldTypeDescription
src?SourceInput | nullThe video to play, which loads afresh when its value changes.
plugins?readonly AnyPlugin[]Set once. Define the array outside the component or memoize it.
load?LoadStrategyWhen the provider and its engine load. Set once. Defaults to eager.
player?PlayerBring your own player instead of creating one.
onError?((error: MediaErrorInfo) => void)Called with every error, fatal or not, for logging. It can change between renders.
children?ReactNodeContent rendered inside the player's root element.
SeekButtonProps
FieldTypeDescription
secondsnumberSeconds to move. Negative goes back.
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
SettingsMenuProps
FieldTypeDescription
children?ReactNodeThe rows at the top level of the menu.
TimeProps
TimeProps
TimelinePartProps
TimelinePartProps
TimelinePreviewProps
FieldTypeDescription
children?ReactNodeShown above the time, such as a thumbnail.
TimelineProps
FieldTypeDescription
step?numberSeconds moved by the arrow keys.
largeStep?numberSeconds moved by Page Up and Page Down.
children?ReactNodeReplaces the default track, thumb, and preview.
TitleProps
FieldTypeDescription
title?ReactNodeThe video's name.
eyebrow?ReactNodeA short line above the title, such as a series or an episode.
description?ReactNodeA sentence or two about the video, which shows while it's paused.
TransportProps
FieldTypeDescription
seekSeconds?numberHow far the buttons on either side of play jump, in seconds.
VolumeProps
VolumeProps
VolumeSliderProps
FieldTypeDescription
step?numberChange per arrow key press, from 0 to 1.