ReferenceDisplay
Title
Displays the resolved content title for the current media
Import
Anatomy
Behavior
The component renders the resolved title directly as text and owns that text: it does
not accept children. Set the title on the player instead.
A title can come from two places. The player uses the first one that has a value:
- The title you set on the player.
- The title the media reports about itself.
If neither has a value, there is nothing to show and the title hides itself.
The title is player input, not player state, so change it the way you set it in the
first place. The store exposes the resolved title to read, and nothing to write.
That resolution belongs to the metadata
feature, which the video and audio presets include.
Set it to null to hand the title back to the media.
The component exposes data-visible while controls are visible. Use that hook to animate
the title with the controls.
Styling
React renders a <div>, or nothing at all when no title resolves. Add a className to
style it:
To fade the title in and out with the controls, use the root’s data-visible attribute:
className and style also accept a function of component state when you would rather
branch in JavaScript than in CSS:
Accessibility
The title is ordinary text, so it reaches assistive technology as content with no ARIA
of its own. The native hidden attribute it sets when there is no title also removes it
from the accessibility tree, so nothing is announced when there is nothing to announce.
Fading the title out with opacity leaves it readable by a screen reader while it is not
painted. That is deliberate — the name of what is playing stays relevant whether or not
the controls happen to be on screen.
The component does not name the player. To give the player region an accessible name,
set aria-label or aria-labelledby on the container yourself.