TrackList

Rows of tracks. The loaded one gets a highlight that glides to it and animated bars while it plays, hovering a row turns its number into a play arrow, and arrow keys move between rows. Media.

Open playground

About

TrackList is a React component in the Media category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { TrackList } from "@ashutoshswamy/smoui" and set tracks, current, playing among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { TrackList } from "@ashutoshswamy/smoui";

<TrackList label="Album tracks" tracks={tracks} current={id} playing={playing} onSelect={toggleOrLoad} />

Props 5

tracks

Each has id, title, artist and duration in seconds.

Track[]
current

Id of the loaded track.

string
playing

Animates the bars on the loaded row.

booleandefault false
onSelect

A row was pressed. Pressing the loaded track should pause or resume.

(id: string) => void
label

Accessible name for the list.

string