ReferenceButtons
PlayButton
Accessible play/pause button with keyboard support and customizable rendering
Import
Anatomy
Behavior
The play button is a three-state button: play, pause, and replay. When media reaches the end (ended state), clicking restarts playback from the beginning.
Styling
Style with the [data-paused] and [data-ended] attributes to show/hide play/pause/replay icons based on state. For example:
React renders a <button> element. Add a className to style it:
After first play, the data-started attribute is added and remains present until a new source is loaded. Use this to hide the play button when media hasn’t started yet:
Accessibility
Renders a <button> element with an automatic aria-label that updates based on state: “Play”, “Pause”, or “Replay”. Override with the label prop, which accepts a text descriptor, literal string, or function returning either. A text descriptor contains an opaque translation key and English fallback, for example { key: 'buttons.play', text: 'Play video' }. Keyboard activation: Enter / Space.