Skip to content

CSS Parts

CSS Parts let you style specific internal elements from outside the Shadow DOM using the ::part() pseudo-element. This gives full control over individual components without modifying the library.

Usage

css
py-audio::part(btn-play) {
  background: linear-gradient(135deg, #ff6b6b, #feca57);
  border-radius: 50%;
  width: 48px;
  height: 48px;
}

Shared Parts (audio + video)

PartElementDescription
rootOuter containerTop-level wrapper element
top-barTitle barHeader with player title
controlsButton groupContainer for playback buttons
btn-playPlay/pause buttonMain playback toggle
btn-prevPrevious buttonGo to previous track/chapter
btn-nextNext buttonGo to next track/chapter
progressProgress bar trackFull-width clickable progress area
progress-fillFilled portionPortion of progress bar that is filled
progress-thumbDrag handleDraggable thumb on progress bar
playlistPlaylist containerWraps all track/chapter items
playlist-itemTrack/chapter rowIndividual entry in the playlist
upload-areaUpload zoneClickable area for file upload
now-playingTrack displayShows current track name

Audio-only Parts

PartElementDescription
visualizerVisualizer containerWraps the frequency bars
viz-barFrequency barIndividual bar in the visualizer

Video-only Parts

PartElementDescription
video-containerVideo wrapperContains the <video> element
video-controlsControls barBottom overlay with all controls
volume-sliderVolume controlSlider for adjusting volume
fullscreen-btnFullscreen toggleButton to enter/exit fullscreen

Examples

Custom play button

css
py-audio::part(btn-play) {
  background: #7c4dff;
  color: white;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 18px;
}

Styled progress bar

css
py-audio::part(progress) {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.1);
}

py-audio::part(progress-fill) {
  background: linear-gradient(90deg, #ff6b6b, #feca57);
  border-radius: 3px;
}

py-audio::part(progress-thumb) {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

Custom outer container

css
py-audio::part(root) {
  border: 2px solid #7c4dff;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(124, 77, 255, 0.2);
}

Playlist item styling

css
py-audio::part(playlist-item) {
  border-radius: 6px;
  padding: 8px 12px;
  transition: background 0.15s;
}

Visualizer bars

css
py-audio::part(viz-bar) {
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #ff6b6b, #feca57);
}

Video controls

css
py-video::part(video-controls) {
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 20px 16px 12px;
}

py-video::part(fullscreen-btn) {
  opacity: 0.8;
}

py-video::part(fullscreen-btn):hover {
  opacity: 1;
}