Skip to content

Dice Roll Card

A gaming card featuring a pair of dice that tumble and roll on hover. The dice show random faces with each roll, featuring etched dots with realistic shadows. Clicking locks the dice and reveals the sum with a dramatic glow.

Dice Roll Card

by FreeCsStyles Dev's

CardsSpin / Rotation / Flip
🌐🎨⚛️💚🅰️🔥☁️
#dice#roll#game#random#tumble#cube#gaming#rpg#board-game#casino

Embed this component

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

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

Implementation code

Copy the HTML and CSS for Dice 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="dice-roll-card">
  <div class="dice-area">
    <div class="dice-cube">
      <div class="dice-face">
        <div class="dot"></div><div class="dot"></div>
        <div class="dot"></div><div class="dot"></div>
        <div class="dot"></div><div class="dot"></div>
      </div>
    </div>
    <div class="dice-cube">
      <div class="dice-face">
        <div class="dot"></div><div class="dot"></div>
        <div class="dot"></div>
      </div>
    </div>
  </div>
  <div class="dice-sum">Sum: 9</div>
  <div class="dice-content">
    <div class="dice-title">Roll the Dice</div>
    <div class="dice-badge">ROLL</div>
  </div>
</div>
CSS
.dice-roll-card { position: relative; width: 220px; min-height: 290px; border-radius: 16px; background: linear-gradient(160deg, #0a1410, #040a08); border: 1.5px solid rgba(100,200,150,0.12); overflow: hidden; cursor: pointer; }
.dice-roll-card:hover { box-shadow: 0 0 30px rgba(100,200,150,0.08); }
.dice-area { position: absolute; left: 50%; top: 35%; transform: translate(-50%,-50%); display: flex; gap: 16px; }
.dice-cube { width: 48px; height: 48px; border-radius: 8px; background: linear-gradient(145deg, #1a2a20, #0e1812); border: 1.5px solid rgba(100,200,150,0.15); display: flex; align-items: center; justify-content: center; transition: transform 0.1s; }
.dice-roll-card:hover .dice-cube { transform: rotate(15deg) scale(1.05); }
.dice-cube:nth-child(2) { transition-delay: 0.05s; }
.dice-face { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #e0e8e0, #80a090); box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.dice-sum { position: absolute; left: 50%; top: 55%; transform: translate(-50%,-50%); font-size: 18px; font-weight: 700; color: rgba(100,200,150,0.6); opacity: 0; transition: opacity 0.3s; }
.dice-roll-card:active .dice-sum { opacity: 1; }
.dice-content { position: absolute; inset-x: 0; bottom: 0; padding: 16px; text-align: center; background: linear-gradient(0deg, rgba(0,0,0,0.7), transparent); }
.dice-title { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.9); }
.dice-badge { font-size: 7px; font-weight: 700; letter-spacing: 0.2em; color: rgba(100,200,150,0.4); margin-top: 4px; }
Tailwind CSS
<div class="group relative w-[220px] min-h-[290px] rounded-2xl bg-gradient-to-b from-[#0a1410] to-[#040a08] border border-emerald-500/20 overflow-hidden cursor-pointer group-hover:shadow-[0_0_30px_rgba(100,200,150,0.08)]">
  <div class="absolute left-1/2 top-[35%] -translate-x-1/2 -translate-y-1/2 flex gap-4">
    <div class="w-12 h-12 rounded-lg bg-gradient-to-br from-[#1a2a20] to-[#0e1812] border border-emerald-500/20 flex items-center justify-center transition-transform group-hover:rotate-[15deg] group-hover:scale-105">
      <div class="grid grid-cols-3 gap-1 p-2">{/* 6 dots */}</div>
    </div>
    <div class="w-12 h-12 rounded-lg bg-gradient-to-br from-[#1a2a20] to-[#0e1812] border border-emerald-500/20 flex items-center justify-center transition-transform [transition-delay:0.05s] group-hover:rotate-[-10deg] group-hover:scale-105">
      <div class="grid grid-cols-3 gap-1 p-2">{/* 3 dots */}</div>
    </div>
  </div>
  <div class="absolute left-1/2 top-[55%] -translate-x-1/2 -translate-y-1/2 text-lg font-bold text-emerald-500/60 opacity-0 transition-opacity group-active:opacity-100">Sum: 9</div>
  <div class="absolute inset-x-0 bottom-0 p-4 text-center bg-gradient-to-t from-black/70 to-transparent">
    <p class="text-sm font-bold text-white/90">Roll the Dice</p>
    <p class="text-[7px] font-bold tracking-widest text-emerald-500/40 mt-1">ROLL</p>
  </div>
</div>
React
import React, { useState, useRef } from 'react';
import { motion } from 'framer-motion';

export function DiceRollCard({ width = 220 }) {
  const [dice, setDice] = useState([1, 6]);
  const [locked, setLocked] = useState(false);
  const faces = [
    [],
    [5],
    [1, 9],
    [1, 5, 9],
    [1, 3, 7, 9],
    [1, 3, 5, 7, 9],
    [1, 3, 4, 6, 7, 9]
  ];
  const dotPositions = [
    null,
    [5],
    [1, 9],
    [1, 5, 9],
    [1, 3, 7, 9],
    [1, 3, 5, 7, 9],
    [1, 3, 4, 6, 7, 9]
  ];
  const roll = () => setDice([Math.ceil(Math.random() * 6), Math.ceil(Math.random() * 6)]);
  return (
    <motion.div
      onHoverStart={() => { if (!locked) { const t = setInterval(roll, 150); (el) => el.onHoverEnd = () => clearInterval(t); }}}
      onClick={() => setLocked(!locked)}
      whileTap={{ scale: 0.97 }}
      className="relative cursor-pointer" style={{ width }}>
      <motion.div className="relative rounded-2xl overflow-hidden" style={{ minHeight: 290, background: 'linear-gradient(160deg, #0a1410, #040a08)', border: '1.5px solid rgba(100,200,150,0.12)' }}>
        <div className="absolute left-1/2 top-[35%] -translate-x-1/2 -translate-y-1/2 flex gap-4">
          {dice.map((val, di) => (
            <motion.div key={di} className="w-12 h-12 rounded-lg flex items-center justify-center"
              style={{ background: 'linear-gradient(145deg, #1a2a20, #0e1812)', border: '1.5px solid rgba(100,200,150,0.15)' }}
              animate={{ rotate: locked ? 0 : [0, 10, -10, 5, -5, 0] }} transition={{ duration: 0.3, repeat: locked ? 0 : Infinity }}>
              <div className="grid grid-cols-3 gap-1 p-2 w-full h-full">
                {[1, 2, 3, 4, 5, 6, 7, 8, 9].map((pos) => (
                  <div key={pos} className="flex items-center justify-center">
                    {dotPositions[val]?.includes(pos) && (
                      <div className="w-1.5 h-1.5 rounded-full" style={{ background: 'radial-gradient(circle at 35% 35%, #e0e8e0, #80a090)', boxShadow: 'inset 0 1px 2px rgba(0,0,0,0.4)' }} />
                    )}
                  </div>
                ))}
              </div>
            </motion.div>
          ))}
        </div>
        <motion.div className="absolute left-1/2 top-[55%] -translate-x-1/2 -translate-y-1/2 text-lg font-bold"
          style={{ color: 'rgba(100,200,150,0.6)' }}
          animate={{ opacity: locked ? 1 : 0 }}>
          Sum: {dice[0] + dice[1]}
        </motion.div>
        <div className="absolute inset-x-0 bottom-0 p-4 text-center" style={{ background: 'linear-gradient(0deg, rgba(0,0,0,0.7), transparent)' }}>
          <p className="text-sm font-bold" style={{ color: 'rgba(255,255,255,0.9)' }}>Roll the Dice</p>
          <p className="text-[7px] font-bold tracking-widest mt-1" style={{ color: 'rgba(100,200,150,0.4)' }}>{locked ? 'LOCKED' : 'ROLL'}</p>
        </div>
      </motion.div>
    </motion.div>
  );
}

Where Dice Roll Card fits

  • Game Cards
  • Board Game UI
  • RPG Tools
  • Casino Interfaces
  • Dice Rollers

Interaction states & animations

  • Dice tumbling rotation
  • Face change animation
  • Dot etched shadow
  • Sum reveal glow
  • Random roll on hover

Topics

  • #dice
  • #roll
  • #game
  • #random
  • #tumble
  • #cube
  • #gaming
  • #rpg
  • #board-game
  • #casino

Accessibility notes

Dice animation may be distracting. prefers-reduced-motion shows static dice with click-to-roll. Dice results announced for screen readers.

Browser support

  • Chrome 76+
  • Firefox 90+
  • Safari 13+
  • Edge 79+