Primitives

The unstyled parts in react-video-kit/primitives, with their props.

Read Headless to see how to use these.

Components

AsChild

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

BufferingIndicator

Sets data-visible while stalled. It writes to the DOM directly, with no renders.

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

The large button over the video, shown before playback starts and after it ends.

PropTypeDescription
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
PlayPause
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

Provides the player to its parts. Never re-renders because of playback.

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

Jumps by a fixed amount. Disabled wherever seeking is, such as during an ad.

PropTypeDescription
secondsnumberSeconds to move. Negative goes back.
asChild?booleanMerges behaviour onto the single child instead of rendering a button.
Slot

Renders what plugins contributed to name, in plugin order.

PropTypeDescription
nameSlotNameThe slot to render, such as overlay or menu.
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
VolumeSlider

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

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

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.
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.
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.
VolumeSliderProps
FieldTypeDescription
step?numberChange per arrow key press, from 0 to 1.