ReferenceButtons
CaptionsButton
Accessible captions toggle button with availability detection and state reflection
Import
Anatomy
Behavior
Toggles captions and subtitles on and off. The button checks the media’s text track list for tracks with kind="captions" or kind="subtitles".
When none are present, the component returns null.
An explicitly disabled button with caption tracks stays visible and focusable with aria-disabled="true" and data-disabled, but does not toggle captions.
When menuTrigger is enabled and multiple caption or subtitle tracks are available, activation opens the linked captions menu instead of toggling captions directly. menuTrigger is enabled automatically when a CaptionsButton is rendered inside Menu.Trigger.
Styling
Style the button based on active state:
React renders a <button> element. Add a className to style it:
Style an explicitly disabled, available button:
The button hides automatically when no caption tracks are available. No availability selector or extra hiding CSS is required.
Accessibility
Renders a <button> with an automatic aria-label: “Disable captions” when active, “Enable captions” when inactive. Override with the label prop. Keyboard activation: Enter / Space.
In menu-trigger mode, the button behaves as a menu trigger and reflects menu state through the trigger attributes.