CaptionsButton toggles captions and subtitles on and off. It checks the media’s text track list for tracks with kind="captions" or kind="subtitles" and reflects availability via a data attribute.
Requires the
textTrack feature to be registered with the player.Import
Basic Usage
Custom Render
Props
Custom render prop. Receives the computed HTML props and current state.
Override the automatic
aria-label. By default: "Enable captions" or "Disable captions".Disables the button.
CSS class name or a function that receives state and returns a class name.
Inline style or a function that receives state and returns a style object.
State Data Attributes
| Attribute | Value / Description |
|---|---|
data-active | Present when captions/subtitles are currently enabled. |
data-availability | "available" | "unavailable" — whether any caption or subtitle tracks exist. |
CSS Styling Example
Accessibility
Renders a<button> element. The aria-label updates automatically: "Enable captions" or "Disable captions". Keyboard activation: Enter / Space.