opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Audio
  4. Now Playing Bar
Back to Audio

Components / Audio

Now Playing Bar

Free Audio React component — NowPlayingBar. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Compact dark player bar with artwork, track info, transport controls, and a scrubber. The footer bar every music app eventually needs.

Preview

Midnight Dreams

Midnight Dreams

The Weekend

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/audio/now-playing-bar.tsx in your project.

  4. 4

    Import and render:

    Example

    import { NowPlayingBar } from "@/components/audio/now-playing-bar";

    <NowPlayingBar />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/audio/now-playing-bar.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"use client";
 
import { forwardRef, type ComponentPropsWithoutRef, useState } from "react";
 
import Image from "next/image";
 
import { cn } from "@/lib/cn";
 
import { Play, Pause, SkipForward, SkipBack } from "lucide-react";
 
export type NowPlayingBarProps = Readonly<
{
title?: string;
artist?: string;
progress?: number;
artwork?: string;
defaultPlaying?: boolean;
} & ComponentPropsWithoutRef<"div">
>;
 
// Production-ready Now Playing component — styled with Tailwind CSS.
export const NowPlayingBar = forwardRef<HTMLDivElement, NowPlayingBarProps>(
(
{
className,
title = "Midnight Dreams",
artist = "The Weekend",
progress = 60,
artwork = "/wallpaper-3.png",
defaultPlaying = true,
...props
},
ref,
) => {
const [playing, setPlaying] = useState(defaultPlaying);
 
return (
<div
ref={ref}
data-slot="now-playing-bar"
className={cn(
"flex w-80 items-center gap-3 rounded-2xl border border-neutral-800 bg-neutral-950 px-3 py-3 font-sans shadow-lg",
className,
)}
{...props}
>
<div
data-slot="now-playing-bar-artwork"
className="relative h-10 w-10 shrink-0 overflow-hidden rounded-lg"
>
<Image
src={artwork}
alt={title}
fill
sizes="40px"
className="object-cover"
/>
</div>
 
<div data-slot="now-playing-bar-info" className="min-w-0 flex-1">
<p className="truncate text-xs font-medium text-white">{title}</p>
 
<p className="truncate text-[10px] text-neutral-500">{artist}</p>
</div>
 
<div
data-slot="now-playing-bar-controls"
className="flex items-center gap-2"
>
<button
type="button"
aria-label="Previous track"
className="cursor-pointer text-sm text-neutral-500 transition-colors hover:text-white"
>
<SkipBack size={14} />
</button>
 
<button
type="button"
aria-label={playing ? "Pause" : "Play"}
onClick={() => setPlaying(!playing)}
className="flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-white text-xs text-neutral-900 transition-transform hover:scale-105"
>
{playing ? (
<Pause size={14} fill="black" />
) : (
<Play size={14} fill="black" />
)}
</button>
 
<button
type="button"
aria-label="Next track"
className="cursor-pointer text-sm text-neutral-500 transition-colors hover:text-white"
>
<SkipForward size={14} />
</button>
</div>
 
<div
data-slot="now-playing-bar-progress"
className="hidden h-1 w-16 overflow-hidden rounded-full bg-neutral-800 sm:block"
>
<div
className="h-full rounded-full bg-emerald-500"
style={{
width: `${Math.min(Math.max(progress, 0), 100)}%`,
}}
/>
</div>
</div>
);
},
);
 
NowPlayingBar.displayName = "NowPlayingBar";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/audio/now-playing-bar.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.