Marble Machine
A marble rolls through gears and levers, activating bells that ring, then Success appears
Marble Machine
by FreeCsStyles Dev's
AnimatedStorybook
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#marble#machine#process#gears#lever#bell
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/marble-machine.
<iframe src="/embed/marble-machine" sandbox="allow-scripts" loading="lazy" title="Marble Machine" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Marble Machine, or grab a framework-specific implementation. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.
HTML
<button class="btn-marble"><span class="marble">🔮</span><span class="text">Process</span></button>CSS
.btn-marble{width:150px;height:50px;border-radius:12px;border:none;background:#7c3aed;color:#fff;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:all .4s;font-family:system-ui,sans-serif}.btn-marble .marble{position:absolute;font-size:16px;left:-25px;transition:all 1s cubic-bezier(.4,0,.2,1);z-index:2}.btn-marble .gear{position:absolute;font-size:14px;right:-25px;opacity:0;transition:all .5s}.btn-marble .text{z-index:1;transition:.3s}.btn-marble.is-rolling .marble{left:60%;transform:translateX(-60%)}.btn-marble.is-rolling .gear{opacity:1;animation:gear-spin .5s linear 3}.btn-marble.is-rolling .text{opacity:0}.btn-marble.is-success{background:#6d28d9;border:1px solid #c084fc}@keyframes gear-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}Tailwind CSS
<button class="w-[150px] h-[50px] rounded-xl border-none bg-purple-700 text-white font-bold cursor-pointer relative flex items-center justify-center overflow-hidden transition-all duration-[400ms] font-sans"><span class="relative z-10">🔮 Process</span></button>React
import { useState } from 'react';
export function MarbleMachine() {
const [phase, setPhase] = useState('idle');
const handleClick = () => {
if (phase !== 'idle') return;
setPhase('rolling');
setTimeout(() => setPhase('success'), 1200);
setTimeout(() => setPhase('idle'), 3500);
};
return (
<button onClick={handleClick} disabled={phase !== 'idle'}
style={{ width: 150, height: 50, borderRadius: 12, border: phase === 'success' ? '1px solid #c084fc' : 'none', background: phase === 'success' ? '#6d28d9' : '#7c3aed', color: '#fff', fontSize: 16, fontWeight: 'bold', cursor: 'pointer', position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden', fontFamily: 'system-ui,sans-serif', transition: 'all 0.4s' }}>
<span>{phase === 'idle' ? '🔮 Process' : phase === 'success' ? '✓ Success' : ''}</span>
</button>
);
}Vue
<template>
<button class="btn-marble" :class="phase" @click="handleClick" :disabled="phase!=='idle'">
<span class="marble">🔮</span>
<span class="gear">⚙️</span>
<span class="text">{{ phase==='idle' ? 'Process' : phase==='success' ? 'Success' : '' }}</span>
</button>
</template>
<script setup>
import { ref } from 'vue';
const phase = ref('idle');
function handleClick() {
if (phase.value !== 'idle') return;
phase.value = 'rolling';
setTimeout(() => phase.value = 'success', 1200);
setTimeout(() => phase.value = 'idle', 3500);
}
</script>Svelte
<script>
let phase = 'idle';
function handleClick() { if (phase !== 'idle') return; phase = 'rolling'; setTimeout(() => phase = 'success', 1200); setTimeout(() => phase = 'idle', 3500); }
</script>
<button class="btn-marble" class:is-success={phase==='success'} on:click={handleClick} disabled={phase!=='idle'}>
<span class="marble">🔮</span>
<span>{phase==='idle' ? '🔮 Process' : phase==='success' ? '✓ Success' : ''}</span>
</button>Angular
import { Component } from '@angular/core';
@Component({
selector: 'app-marble-machine',
template: `<button class="btn-marble" [class.is-rolling]="phase==='rolling'" [class.is-success]="phase==='success'" (click)="handleClick()" [disabled]="phase!=='idle'"><span>{{ phase==='idle' ? '🔮 Process' : phase==='success' ? '✓ Success' : '' }}</span></button>`,
styles: [`.btn-marble{width:150px;height:50px;border-radius:12px;border:none;background:#7c3aed;color:#fff;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}.btn-marble.is-success{background:#6d28d9;border:1px solid #c084fc}`]
})
export class MarbleMachineComponent { phase='idle';handleClick(){if(this.phase!=='idle')return;this.phase='rolling';setTimeout(()=>this.phase='success',1200);setTimeout(()=>this.phase='idle',3500);}}LWC — HTML template
<template><button class="btn-marble" onclick={handleClick} disabled={disabled}><span>{label}</span></button></template>LWC — JavaScript
import { LightningElement } from 'lwc';
export default class MarbleMachine extends LightningElement {
phase = 'idle';
get disabled() { return this.phase !== 'idle'; }
get label() { return this.phase==='idle'?'🔮 Process':this.phase==='success'?'✓ Success':''; }
handleClick() { if(this.phase!=='idle')return;this.phase='rolling';setTimeout(()=>this.phase='success',1200);setTimeout(()=>this.phase='idle',3500); }
}LWC — CSS
.btn-marble{width:150px;height:50px;border-radius:12px;border:none;background:#7c3aed;color:#fff;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:all .4s}.btn-marble.is-success{background:#6d28d9;border:1px solid #c084fc}LWC — Configuration
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets><target>lightning__AppPage</target><target>lightning__RecordPage</target><target>lightning__HomePage</target></targets>
</LightningComponentBundle>Where Marble Machine fits
- Process Actions
- Processing
- Calculation
- Loading
Interaction states & animations
- Marble Roll
- Gear Rotation
- Bell Ring
Topics
- #marble
- #machine
- #process
- #gears
- #lever
- #bell
Accessibility notes
Animation is decorative. Button text remains readable. Respect reduced-motion preference.
Browser support
- All modern browsers