SpotifyNowPlaying

Now-playing line with scroll-flip transitions and optional polling.

Usage

svelte
<script lang="ts">
  import { SpotifyNowPlaying } from "@milandekruijf/ui/svelte";

  const nowPlaying = {
    playing: true,
    title: "Cornfield Chase",
    artist: "Hans Zimmer",
    url: "https://open.spotify.com",
  };
</script>

<SpotifyNowPlaying {nowPlaying} pollUrl="/api/spotify/now-playing" />

Examples

Now playing
<script lang="ts">
  import { SpotifyNowPlaying } from "@milandekruijf/ui/svelte";

  const nowPlaying = {
    playing: true,
    title: "Cornfield Chase",
    artist: "Hans Zimmer",
    url: "#",
  };
</script>

<SpotifyNowPlaying {nowPlaying} profileUrl="#" pollUrl={null} />

Props

PropTypeDefaultDescription
nowPlayingNowPlaying—
Initial track as `{ playing, title, artist, url }` or `null` for the idle state.
pollUrl?string | nullnull
Endpoint polled for fresh data; skipped when null.
profileUrl?string"https://open.spotify.com"
Where the idle state links to.
formatLabel?(np: NowPlaying) => string—
Localized accessible label for a given state; defaults to an English label.
class?string—
Extra classes merged on the root.