1. Buttons
  2. Play Button

Buttons

Play Button

This component is used to play and pause media.

Usage

The <media-play-button> component will toggle the paused state of media as it's pressed by dispatching a media-play-request, and media-pause-request event to the player.

          
        

Key Shortcuts

Keyboard shortcuts can be specified either through the global key shortcuts config, or on the component like so:

          
        

👉 See the aria-keyshortcuts docs for more information.

Custom Icons

Here's an example containing a custom play and pause icon:

          
        

Tooltips

Tooltips can be provided like so:

          
        

Styling

You can override the default styles with CSS like so:

css
        media-play-button {
  color: pink;
  transition: opacity 0.2s ease-in;
}

/* Apply styles when media is paused. */
media-play-button[data-paused] {
}

/* Apply styles when media is _not_ paused. */
media-play-button:not([data-paused]) {
}

/* Apply styles when media has ended. */
media-play-button[data-ended] {
}

/* Style default icons. */
media-play-button svg[slot='play'] {
}
media-play-button svg[slot='pause'] {
}
media-play-button svg[slot='replay'] {
}

      

Focus

css
        media-play-button {
  /* box shadow */
  --media-focus-ring: 0 0 0 4px rgb(78 156 246);
}

/* Apply styles when focused via keyboard. */
media-play-button[data-focus] {
}

      

Tailwind

The following is a headless example using Tailwind:

          
        

Tooltips

The following extends the example above with tooltips: