Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Podcast Player

ProNew

A podcast page: show header with follow links, episodes with descriptions and lengths, and a docked player with skip back 15, forward 30, speed and progress that remembers where each episode was left.

Installation

pnpm dlx shadcn@latest add @viewport/podcast-player

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
show*PodcastShow

The show the header describes.

—
episodes*PodcastEpisode[]

Episodes, newest first.

—
layout"page" | "compact" | "bar"

`page` is the full show page with descriptions, `compact` is a tighter card with one line per episode, and `bar` is the player alone with the episodes in a panel that opens above it.

"page"
heightnumber

Caps the height in pixels: the list scrolls inside and the player stays docked at the bottom.

—
pageSizenumber

Episodes shown before the "Show more" button. 0 shows all of them.

5
skipBacknumber

Seconds the back button jumps.

15
skipForwardnumber

Seconds the forward button jumps.

30
speedsnumber[]

Playback rates the speed button steps through. An empty list hides it.

[1, 1.25, 1.5, 2, 0.75]
continuousboolean

Play the next episode in the list when one ends.

true
defaultIndexnumber

Episode selected at first.

0
defaultVolumenumber

Volume at first, from 0 to 1.

1
localestring

Locale used to write dates.

"en-US"
loadingboolean

Draws a placeholder while the feed is being fetched.

false
disabledboolean

Turns every control off.

false
labelstring

Accessible name of the player.

—
onEpisodeChange(index: number, episode: PodcastEpisode) => void

Called when another episode is selected.

—
onPlayingChange(playing: boolean) => void

Called when sound starts or stops.

—
classNamestring—

Accessibility

  • Each episode has its own button named Play or Pause plus the episode title, the selected one carries aria-current, and long descriptions open with a Show more button that reports its state.
  • The docked player is a named group: Back 15 seconds, Play, Forward 30 seconds, a seek slider that reads elapsed and total time, a speed button that says the current rate, and volume.
  • Show more episodes moves focus to the first new episode, an episode change is announced politely, and a file that fails to load raises an alert with Retry.
  • With a fixed height the scrolling list is focusable so it can be scrolled by keyboard; under reduced motion the equalizer, spinner and panel slide stand still.