Skip to content
FrameworkStyle

QualityRadioGroup

A menu radio group for selecting video quality

Creates radio items from the player video rendition state and selects automatic or manual quality.

Import

import { QualityRadioGroup } from '@videojs/react/ui/quality-radio-group';

Anatomy

<QualityRadioGroup.Root>
  <Menu.Trigger>
    <QualityRadioGroup.Value />
  </Menu.Trigger>
  <Menu.Content>
    <QualityRadioGroup.Options
      renderItem={(props, item) => (
        <Menu.RadioItem {...props}>
          {item.label}
          <Menu.ItemIndicator checked={item.checked} />
        </Menu.RadioItem>
      )}
    />
  </Menu.Content>
</QualityRadioGroup.Root>

Behavior

The group is available when the configured media exposes more than one video rendition. The first generated option is Auto; selecting it returns control to adaptive bitrate selection. Pass formatRendition to customize visible rendition labels.

QualityRadioGroup.Root uses useQualityOptions to own selection and renders no element. Wrap the menu’s Menu.Trigger and Menu.Content in it so the trigger inherits the group’s disabled and hidden state and exposes data-availability. QualityRadioGroup.Options renders the items: its required renderItem callback renders the Menu.RadioItem root and receives item state containing the translated label, optional tier and badge, and current checked value. QualityRadioGroup.Value displays the selected label, typically inside the trigger. Options and Value render null when the quality feature is not configured.

The QualityRadioGroup export from the @videojs/react root is a compatibility component that composes Root and Options behind the former single-component props. Prefer the parts for new code.

Styling

Attribute Values Description
data-quality string Current quality value.
data-disabled Present / absent Present when quality selection is disabled.
data-hidden Present / absent Present when multiple renditions are unavailable.
data-availability "available" / "unavailable" Whether multiple renditions are available.

Unavailable groups receive the native hidden attribute.

Accessibility

The group uses the menu radio group pattern.

QualityRadioGroup.Options receives its accessible label from the label prop on QualityRadioGroup.Root or defaults to Quality. Override it with aria-label or aria-labelledby on QualityRadioGroup.Options.

Examples

Basic usage

import { Container, createPlayer, Menu } from '@videojs/react';
import { HlsJsVideo } from '@videojs/react/media/hlsjs-video';
import { QualityRadioGroup } from '@videojs/react/ui/quality-radio-group';
import { videoFeatures } from '@videojs/react/video';
import type { ReactNode } from 'react';

const { Player } = createPlayer({ features: videoFeatures });
const src = 'https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4.m3u8';

function QualityMenu(): ReactNode {
  return (
    <Menu.Root side="top" align="end">
      <QualityRadioGroup.Root>
        <Menu.Trigger className="settings-trigger" render={<button type="button" />}>
          Quality
          <QualityRadioGroup.Value className="menu-hint" />
        </Menu.Trigger>
        <Menu.Popup className="menu">
          <Menu.Content>
            <QualityRadioGroup.Options
              className="menu-group"
              renderItem={(props, item) => (
                <Menu.RadioItem {...props} className="menu-item">
                  <span>
                    {item.label}
                    {item.tier ? <sup className="menu-tier">{item.tier}</sup> : null}
                  </span>
                  {item.badge ? <span className="menu-badge">{item.badge}</span> : null}
                  <Menu.ItemIndicator checked={item.checked} forceMount className="menu-indicator">

                  </Menu.ItemIndicator>
                </Menu.RadioItem>
              )}
            />
          </Menu.Content>
        </Menu.Popup>
      </QualityRadioGroup.Root>
    </Menu.Root>
  );
}

export default function BasicUsage() {
  return (
    <Player>
      <Container className="media-container">
        <HlsJsVideo src={src} autoPlay crossOrigin="anonymous" muted playsInline loop />
        <div className="menu-bar">
          <QualityMenu />
        </div>
      </Container>
    </Player>
  );
}

API Reference

Root

Owns quality option state and shares it with an enclosing menu. Does not render a DOM element.

Props

PropTypeDefaultDetails
disabledbooleanfalse
formatRenditionstring) | functionformatRenditionLabel
labelobject''

State

State is accessible via the render, className, and style props.

PropertyTypeDetails
label{ key: string; text: string } | string
valuestring
optionsreadonly Option[]
disabledboolean
hiddenboolean
availability'available' | 'unavailable'

Data attributes

AttributeTypeDetails
data-qualitystring
data-disabled
data-hidden
data-availability'available' | 'unavailable'

Options

Renders menu radio items for the player's video renditions.

Props

PropTypeDefaultDetails
classNamestring | ((state: QualityRadioGroupCore.State) => string | undefined)
renderReactElement | ((props: HTMLProps, state: QualityRadioGroupCore.State) => ReactElement | null)
renderItem((props: QualityRadioGroupItemProps, state: QualityRadioGroupItemState) => ReactElement)
styleCSSProperties | ((state: QualityRadioGroupCore.State) => CSSProperties | undefined)

Value

Displays the selected quality label.

Props

PropTypeDefaultDetails
classNamestring | ((state: QualityOptionsResult) => string | undefined)
renderReactElement | ((props: HTMLProps, state: QualityOptionsResult) => ReactElement | null)
styleCSSProperties | ((state: QualityOptionsResult) => CSSProperties | undefined)