Skip to content

Player Piano Roll Card

The card is a continuous piano roll, slowly scrolling upwards. Content is punched as holes in the paper which play as notes when they pass a glowing reader bar. Hovering over a hole previews its musical note. Clicking creates a new punch hole as a bookmark or reaction. Tempo adjusts based on interaction.

Player Piano Roll Card

by FreeCsStyles Dev's

CardsPiano Roll
🌐🎨⚛️💚🅰️🔥☁️
#piano#music#roll#scroll#notes#melody#player-piano#interactive#paper#vintage

Embed this component

Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/player-piano-roll-card.

<iframe src="/embed/player-piano-roll-card" sandbox="allow-scripts" loading="lazy" title="Player Piano Roll Card" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Player Piano Roll Card, or grab a framework-specific implementation. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.

HTML
<div class="piano-card" onclick="punchHole(event)">
  <div class="piano-roll" id="piano-roll"></div>
  <div class="piano-reader"></div>
  <div class="piano-content">
    <div class="piano-header">
      <div><div class="piano-title">Piano Roll</div><div class="piano-sub">Nocturne</div></div>
      <div class="piano-status">♪ 60 BPM</div>
    </div>
    <div class="piano-divider"></div>
    <div class="piano-grid">
      <div class="piano-stat"><div class="piano-stat-val" id="note-count">20</div><div class="piano-stat-lbl">Notes</div></div>
      <div class="piano-stat"><div class="piano-stat-val" id="hover-note">—</div><div class="piano-stat-lbl">Hover Note</div></div>
    </div>
    <div class="piano-hint">[▼ click to punch a note]</div>
  </div>
</div>
<script>
let noteCount = 20;
function punchHole(e) {
  noteCount++;
  document.getElementById('note-count').textContent = noteCount;
}
</script>
CSS
.piano-card {
  position: relative;
  width: 220px;
  min-height: 300px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #1a1410, #0f0c08);
  border: 1.5px solid rgba(210,180,140,0.12);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: all 0.4s ease;
}

.piano-card:hover {
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(210,180,140,0.05);
}

.piano-roll {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(210,180,140,0.03) 40px, rgba(210,180,140,0.03) 41px);
}

.piano-reader {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 3px;
  top: 55%;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(210,180,140,0.3), transparent);
}

.piano-reader::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(210,180,140,0.4);
  animation: readerPulse 1.5s ease-in-out infinite;
}

.piano-content {
  position: absolute;
  inset-x: 0;
  bottom: 0;
  z-index: 10;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(0deg, rgba(15,12,8,0.95), rgba(15,12,8,0.4), transparent);
}

.piano-header { display: flex; justify-content: space-between; align-items: center; }
.piano-title { font-size: 14px; font-weight: 700; color: rgba(210,180,140,0.9); }
.piano-sub { font-size: 9px; color: rgba(210,180,140,0.44); }
.piano-status { padding: 2px 8px; border-radius: 2px; font-size: 7px; font-weight: 700; letter-spacing: 0.1em; color: rgba(210,180,140,0.7); background: rgba(210,180,140,0.08); border: 1px solid rgba(210,180,140,0.12); }
.piano-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(210,180,140,0.08), transparent); }
.piano-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.piano-stat { text-align: center; padding: 6px 4px; border-radius: 8px; background: rgba(210,180,140,0.02); border: 1px solid rgba(210,180,140,0.06); }
.piano-stat-val { font-size: 10px; font-weight: 600; color: rgba(210,180,140,0.6); }
.piano-stat-lbl { font-size: 7px; margin-top: 2px; color: rgba(255,255,255,0.2); }
.piano-hint { text-align: center; font-size: 7px; font-family: monospace; color: rgba(210,180,140,0.2); }

@keyframes readerPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
  .piano-roll { animation: none; }
}
Tailwind CSS
<div class="group relative w-[220px] min-h-[300px] rounded-2xl overflow-hidden border border-amber-800/20 shadow-lg group-hover:shadow-[0_20px_50px_rgba(0,0,0,0.5),inset_0_0_20px_rgba(210,180,140,0.05)] bg-gradient-to-b from-[#1a1410] to-[#0f0c08] cursor-pointer">
  <div class="absolute inset-0 z-2 pointer-events-none" style="background: repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(210,180,140,0.03) 40px, rgba(210,180,140,0.03) 41px);"></div>
  <div class="absolute left-[5%] right-[5%] h-[3px] top-[55%] z-5 pointer-events-none bg-gradient-to-r from-transparent via-amber-600/30 to-transparent">
    <div class="absolute -left-1 -top-[3px] w-[9px] h-[9px] rounded-full bg-amber-600/40 animate-pulse"></div>
  </div>
  <div class="absolute inset-x-0 bottom-0 z-10 p-5 space-y-2 bg-gradient-to-t from-[#0f0c08]/95 via-[#0f0c08]/40 to-transparent">
    <div class="flex items-center justify-between">
      <div><p class="text-sm font-bold text-amber-200/90">Piano Roll</p><p class="text-[9px] text-amber-600/50">Nocturne</p></div>
      <div class="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest text-amber-600/70 bg-amber-500/10 border border-amber-500/20">♪ 60 BPM</div>
    </div>
    <div class="h-px bg-gradient-to-r from-transparent via-amber-600/20 to-transparent"></div>
    <div class="grid grid-cols-2 gap-2">
      <div class="text-center py-1.5 rounded-lg bg-amber-500/10 border border-amber-500/20"><p class="text-[10px] font-semibold text-amber-600/60" id="note-count">20</p><p class="text-[7px] mt-0.5 text-white/20">Notes</p></div>
      <div class="text-center py-1.5 rounded-lg bg-amber-500/10 border border-amber-500/20"><p class="text-[10px] font-semibold text-amber-600/60" id="hover-note">—</p><p class="text-[7px] mt-0.5 text-white/20">Hover Note</p></div>
    </div>
    <div class="text-center"><span class="text-[7px] font-mono text-amber-600/30">[▼ click to punch a note]</span></div>
  </div>
</div>
React
import React, { useState, useRef, useEffect, useCallback } from 'react';
import { motion, useMotionValue, useSpring, AnimatePresence } from 'framer-motion';

const NOTES = ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5'];
const NOTE_COLORS = { 'C4': '#ef4444', 'D4': '#f97316', 'E4': '#eab308', 'F4': '#22c55e', 'G4': '#3b82f6', 'A4': '#8b5cf6', 'B4': '#ec4899', 'C5': '#06b6d4' };

export function PlayerPianoRollCard() {
  const [isHovered, setIsHovered] = useState(false);
  const [scrollPos, setScrollPos] = useState(0);
  const [hoverNote, setHoverNote] = useState(null);
  const [hoverHole, setHoverHole] = useState(null);
  const [activeNotes, setActiveNotes] = useState([]);
  const [punchHoles, setPunchHoles] = useState(Array.from({ length: 20 }, (_, i) => ({ id: i, x: 15 + Math.random() * 55, y: i * 60, note: NOTES[Math.floor(Math.random() * 8)], played: false })));
  const ref = useRef(null);
  const x = useMotionValue(0);
  const y = useMotionValue(0);
  const rotateX = useSpring(y, { damping: 25, stiffness: 250 });
  const rotateY = useSpring(x, { damping: 25, stiffness: 250 });
  
  const handleMouseMove = (e) => {
    if (!ref.current) return;
    const rect = ref.current.getBoundingClientRect();
    const cx = rect.left + rect.width / 2;
    const cy = rect.top + rect.height / 2;
    x.set(-((e.clientX - cx) / (rect.width / 2)) * 8);
    y.set(((e.clientY - cy) / (rect.height / 2)) * 8);
  };

  useEffect(() => {
    let anim; let prev = performance.now();
    const loop = (time) => {
      const dt = (time - prev) / 1000; prev = time;
      setScrollPos((s) => { const n = s + (isHovered ? 60 : 30) * dt; return n > punchHoles.length * 60 + 300 ? 0 : n; });
      anim = requestAnimationFrame(loop);
    };
    anim = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(anim);
  }, [isHovered, punchHoles.length]);

  useEffect(() => {
    const playing = punchHoles.filter((h) => { const sy = h.y - scrollPos; return sy > 40 && sy < 70 && !h.played; });
    if (playing.length > 0) {
      setActiveNotes((p) => [...p, ...playing.map((h) => ({ note: h.note, x: h.x, y: h.y - scrollPos }))]);
      setPunchHoles((prev) => prev.map((h) => playing.some((p) => p.id === h.id) ? { ...h, played: true } : h));
      setTimeout(() => setActiveNotes([]), 600);
    }
  }, [scrollPos]);

  const handleClick = (e) => {
    const newNote = NOTES[Math.floor(Math.random() * 8)];
    setPunchHoles((p) => [...p, { id: Date.now(), x: 15 + Math.random() * 55, y: punchHoles.length * 60 + Math.random() * 60, note: newNote, played: false }]);
  };

  return (
    <div onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => { setIsHovered(false); x.set(0); y.set(0); setHoverHole(null); setHoverNote(null); }}>
      <motion.div ref={ref} onMouseMove={handleMouseMove} onClick={handleClick} style={{ rotateX, rotateY, transformStyle: 'preserve-3d', cursor: 'pointer' }}>
        <motion.div className="relative overflow-hidden rounded-2xl" style={{ width: 220, minHeight: 300, background: 'linear-gradient(180deg, #1a1410, #0f0c08)', border: '1.5px solid rgba(210,180,140,0.12)' }}
          animate={{ boxShadow: isHovered ? '0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(210,180,140,0.05)' : '0 10px 30px rgba(0,0,0,0.4)' }} transition={{ type: 'spring', stiffness: 280, damping: 20 }}>
          <div className="absolute inset-x-0 bottom-0 z-10 p-5 space-y-2" style={{ background: 'linear-gradient(0deg, rgba(15,12,8,0.95), rgba(15,12,8,0.4), transparent)' }}>
            <div className="flex items-center justify-between">
              <div><p className="text-sm font-bold" style={{ color: 'rgba(210,180,140,0.9)' }}>Piano Roll</p><p className="text-[9px]" style={{ color: 'rgba(210,180,140,0.44)' }}>Nocturne</p></div>
              <motion.div className="px-2 py-0.5 rounded-sm text-[7px] font-bold tracking-widest" style={{ background: 'rgba(210,180,140,0.08)', border: '1px solid rgba(210,180,140,0.12)', color: 'rgba(210,180,140,0.7)' }}>♪ {isHovered ? 60 : 30} BPM</motion.div>
            </div>
            <div className="h-px" style={{ background: 'linear-gradient(90deg, transparent, rgba(210,180,140,0.08), transparent)' }} />
            <div className="grid grid-cols-2 gap-2">
              <div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(210,180,140,0.02)', border: '1px solid rgba(210,180,140,0.06)' }}><p className="text-[10px] font-semibold" style={{ color: 'rgba(210,180,140,0.6)' }}>{punchHoles.length}</p><p className="text-[7px] mt-0.5 text-white/20">Notes</p></div>
              <div className="text-center py-1.5 rounded-lg" style={{ background: 'rgba(210,180,140,0.02)', border: '1px solid rgba(210,180,140,0.06)' }}><p className="text-[10px] font-semibold" style={{ color: 'rgba(210,180,140,0.6)' }}>{hoverNote || '—'}</p><p className="text-[7px] mt-0.5 text-white/20">Hover Note</p></div>
            </div>
            <motion.div className="text-center" animate={isHovered ? { y: [0, -1, 0] } : {}} transition={{ duration: 1.5, repeat: isHovered ? Infinity : 0, ease: 'easeInOut' }}>
              <span className="text-[7px] font-mono" style={{ color: 'rgba(210,180,140,0.2)' }}>[▼ click to punch a note]</span>
            </motion.div>
          </div>
        </motion.div>
      </motion.div>
    </div>
  );
}

Where Player Piano Roll Card fits

  • Music Discovery
  • Timeline
  • Scrolling Content
  • Playlist UI
  • Interactive Archives

Interaction states & animations

  • Scroll
  • Note trigger
  • Paper roll
  • Burst particles
  • Glow pulse

Topics

  • #piano
  • #music
  • #roll
  • #scroll
  • #notes
  • #melody
  • #player-piano
  • #interactive
  • #paper
  • #vintage

Accessibility notes

Fast-scrolling content may be disorienting. Consider providing pause controls. Ensure music note indicators have text labels. Add prefers-reduced-motion to pause auto-scroll.

Browser support

  • Chrome 90+
  • Firefox 105+
  • Safari 15+
  • Edge 90+