A vinyl record player built with pure CSS and a little vanilla JavaScript: a walnut turntable with a spinning record, the album cover as the center label, a tonearm that swings onto the grooves, and a now-playing panel with progress bar, transport buttons and a tracklist. Use it on a band, label or podcast page.
How it works
The root section.vr-player is a two-column grid on wide screens. The left .vr-deck is the plinth; it sets container-type: inline-size, so every turntable part is sized in cqw units and scales with the card. .vr-platter holds the .vr-record, whose grooves are a repeating-radial-gradient, with the img.vr-label cover in the middle. A conic gradient on .vr-platter::after adds a light reflection that stays still while the record turns underneath. .vr-pivot and the .vr-arm (counterweight, rod and headshell) form the tonearm.
Everything visual depends on the .is-playing class on the root. It sets animation-play-state: running for the vr-spin keyframes, rotates .vr-arm from --vr-arm-rest to --vr-arm-play, lights the .vr-led and swaps the pause and play icons. The script toggles that class from the .vr-play button, advances the elapsed time once per second, writes it to --vr-progress and the .vr-time-current label, and moves to the next track when one ends. Clicking a .vr-track starts that song, .vr-prev restarts the track or goes back, and the .vr-rpm buttons switch --vr-spin between 33 and 45 rpm. Without JavaScript the record still spins in its initial state.
Customization
--vr-accenton.vr-player: color of the play button, progress bar, active track and selected speed.--vr-wood-1and--vr-wood-2: the two gradient stops of the plinth, e.g.#d8d2c8and#a49c90for a light oak look.--vr-spin: seconds per turn; theSPINobject inscript.jsholds the values for the 33 and 45 buttons.--vr-arm-play: tonearm angle while playing; lower values put the stylus closer to the edge of the record.data-vr-starton the root: the elapsed seconds shown on first load;data-vr-durationon each.vr-tracksets its length.- Remove
is-playingfrom the root to load the player paused with the arm resting.
The album cover is a photo from Unsplash; replace it with your own square artwork.
Use cases
- Band and artist websites: a spinning record with the album cover as its label presents the latest release
- Record label pages: visitors click tracks in the tracklist and watch the tonearm swing onto the record
- Podcast pages: a now-playing panel with progress bar and transport buttons adds a retro look to episode lists
- Music blogs and portfolios: 33 and 45 rpm buttons let visitors change how fast the record turns
Accessibility
All controls are real button elements with visible focus outlines. The transport buttons have aria-label values, and the play button switches between "Play" and "Pause". The speed buttons use aria-pressed inside a labelled group, the playing song is marked with aria-current, and the "now playing" line is an aria-live region so track changes are announced. The progress bar exposes role="progressbar" with aria-valuenow and a readable aria-valuetext. The decorative tonearm and LED are hidden from assistive tech. With prefers-reduced-motion the record stops spinning and the arm moves without animation.
Usage notes
The player simulates playback with a timer. To play real audio, add an audio element and call play() and pause() inside setPlaying(), using its timeupdate event instead of tick(). Several players can share a page.