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

Radio Player

ProNew

A live radio player: station list with logos, a live badge, what is on air and volume, in card, bar and mini layouts. Stream URLs come in through props.

Installation

pnpm dlx shadcn@latest add @viewport/radio-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
stations*RadioStation[]

The stations to tune between.

—
layout"card" | "bar" | "mini"

`card` shows a large logo beside the controls, `bar` is a slim strip for the bottom of a page, and `mini` is a small card for a corner.

"card"
listboolean

Show the station list. Defaults to on when there is more than one station.

—
defaultListOpenboolean

Whether the station list starts open.

true
defaultIndexnumber

Station tuned in at first.

0
defaultVolumenumber

Volume at first, from 0 to 1.

1
liveLabelstring

Text of the badge beside the station name.

"Live"
volumeboolean

Show the volume control.

true
loadingboolean

Draws a placeholder while the station list is being fetched.

false
disabledboolean

Turns every control off.

false
labelstring

Accessible name of the player.

"Radio player"
onStationChange(index: number, station: RadioStation) => void

Called when another station is tuned in.

—
onPlayingChange(playing: boolean) => void

Called when sound starts or stops.

—
classNamestring—

Accessibility

  • Stations are a list of native buttons; the tuned one carries aria-current and says whether it is playing, paused or off air, and Previous and Next station wrap around the list.
  • The now-playing line is a polite live region, so a new song is read out when your metadata changes, and tuning to another station is announced.
  • Pausing drops the stream and Play rejoins it live; a station that cannot be reached shows Off air and raises an alert with a Retry button.
  • Under reduced motion the equalizer, the pulse in the live badge, the connecting spinner and the list slide stand still.