Tiny Blacksmith
Build button with blacksmith hammering, sparks, forging, and polishing animation
Tiny Blacksmith
by FreeCsStyles Dev's
AnimatedStorybook
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#blacksmith#forge#build#hammer#sparks#craft
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/tiny-blacksmith.
<iframe src="/embed/tiny-blacksmith" sandbox="allow-scripts" loading="lazy" title="Tiny Blacksmith" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Tiny Blacksmith, 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="blacksmith-container">
<button class="blacksmith-button" onclick="buildForge()">
<span class="anvil-icon">🔨</span>
<span class="button-text">Build</span>
<div class="blacksmith"></div>
<div class="hammer"></div>
<div class="sparks"></div>
<div class="forge-glow"></div>
<div class="sword"></div>
<div class="polish"></div>
</button>
</div>CSS
.blacksmith-container {
display: flex;
justify-content: center;
align-items: center;
padding: 2rem;
}
.blacksmith-button {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-button:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.anvil-icon {
margin-right: 0.5rem;
transition: transform 0.3s ease;
}
.blacksmith {
position: absolute;
bottom: 10px;
left: 20%;
width: 15px;
height: 20px;
background: #374151;
border-radius: 2px;
opacity: 0;
}
.blacksmith-button.animating .blacksmith {
animation: blacksmith-appear 0.3s ease-out forwards;
}
@keyframes blacksmith-appear {
0% { opacity: 0; transform: scale(0); }
100% { opacity: 1; transform: scale(1); }
}
.hammer {
position: absolute;
bottom: 30px;
left: 22%;
width: 20px;
height: 8px;
background: #78350f;
border-radius: 2px;
opacity: 0;
transform-origin: left center;
}
.blacksmith-button.animating .hammer {
animation: hammer-strike 0.2s ease-in-out 4;
}
@keyframes hammer-strike {
0% { transform: rotate(0deg); }
50% { transform: rotate(-45deg); }
100% { transform: rotate(0deg); }
}
.sparks {
position: absolute;
top: 50%;
left: 30%;
width: 5px;
height: 5px;
background: #fbbf24;
border-radius: 50%;
opacity: 0;
}
.blacksmith-button.animating .sparks {
animation: sparks-fly 0.8s ease-out 0.3s forwards;
}
@keyframes sparks-fly {
0% { opacity: 1; transform: translate(0, 0) scale(1); }
100% { opacity: 0; transform: translate(20px, -30px) scale(0); }
}
.forge-glow {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0;
height: 0;
background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent);
border-radius: 50%;
opacity: 0;
}
.blacksmith-button.animating .forge-glow {
animation: forge-glow 1s ease-in-out 1s forwards;
}
@keyframes forge-glow {
0% { width: 0; height: 0; opacity: 0; }
50% { width: 60px; height: 60px; opacity: 1; }
100% { width: 40px; height: 40px; opacity: 0.8; }
}
.sword {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(45deg);
width: 4px;
height: 30px;
background: linear-gradient(to bottom, #d1d5db, #9ca3af);
border-radius: 2px;
opacity: 0;
}
.blacksmith-button.animating .sword {
animation: sword-forged 0.5s ease-out 1.5s forwards;
}
@keyframes sword-forged {
0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); }
100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); }
}
.polish {
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
opacity: 0;
}
.blacksmith-button.animating .polish {
animation: polish-shine 0.6s ease-in-out 2s forwards;
}
@keyframes polish-shine {
0% { left: -100%; opacity: 0; }
50% { opacity: 1; }
100% { left: 100%; opacity: 0; }
}
.blacksmith-button.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.blacksmith-button:disabled {
opacity: 0.7;
cursor: not-allowed;
}
@media (prefers-reduced-motion: reduce) {
.blacksmith-button.animating * {
animation: none !important;
}
}Tailwind CSS
<div class="flex justify-center items-center p-8">
<button class="relative px-8 py-4 bg-gradient-to-r from-amber-800 to-amber-900 text-amber-100 font-bold rounded-xl overflow-hidden transition-all hover:-translate-y-1 hover:shadow-lg hover:shadow-amber-800/40 active:scale-95">
<span class="mr-2">🔨</span>
<span>Build</span>
<div class="absolute inset-0 pointer-events-none">
<div class="absolute bottom-2 left-1/4 w-4 h-5 bg-gray-700 rounded-sm animate-hammer"></div>
<div class="absolute inset-0 bg-gradient-to-r from-transparent via-amber-400/30 to-transparent -translate-x-full animate-polish"></div>
<div class="absolute top-1/2 left-1/2 w-1 h-8 bg-gradient-to-b from-gray-300 to-gray-500 rounded-full -translate-x-1/2 -translate-y-1/2 rotate-45 scale-0 animate-sword"></div>
</div>
</button>
</div>
<style>
@keyframes hammer {
0%, 100% { transform: rotate(0deg); }
50% { transform: rotate(-45deg); }
}
@keyframes polish {
0% { transform: translateX(-100%); opacity: 0; }
50% { opacity: 1; }
100% { transform: translateX(100%); opacity: 0; }
}
@keyframes sword {
0% { transform: translate(-50%, -50%) rotate(45deg) scale(0); }
100% { transform: translate(-50%, -50%) rotate(45deg) scale(1); }
}
.animate-hammer { animation: hammer 0.2s ease-in-out infinite; }
.animate-polish { animation: polish 2s ease-in-out infinite; }
.animate-sword { animation: sword 1s ease-out forwards; }
</style>React
import { useState, useEffect } from 'react';
function TinyBlacksmithButton() {
const [phase, setPhase] = useState('idle');
const handleClick = () => {
if (phase === 'animating') return;
setPhase('animating');
setTimeout(() => {
setPhase('success');
setTimeout(() => setPhase('idle'), 2000);
}, 2500);
};
return (
<>
<style>{`
.blacksmith-btn {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-btn.animating {
background: linear-gradient(135deg, #b45309, #92400e);
}
.blacksmith-btn.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.blacksmith-btn:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.forge-element {
position: absolute;
opacity: 0;
}
.blacksmith {
bottom: 10px;
left: 20%;
width: 15px;
height: 20px;
background: #374151;
border-radius: 2px;
}
.hammer {
bottom: 30px;
left: 22%;
width: 20px;
height: 8px;
background: #78350f;
border-radius: 2px;
transform-origin: left center;
}
.sparks {
top: 50%;
left: 30%;
width: 5px;
height: 5px;
background: #fbbf24;
border-radius: 50%;
}
.forge-glow {
top: 50%;
left: 50%;
width: 0;
height: 0;
background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent);
border-radius: 50%;
transform: translate(-50%, -50%);
}
.sword {
top: 50%;
left: 50%;
width: 4px;
height: 30px;
background: linear-gradient(to bottom, #d1d5db, #9ca3af);
border-radius: 2px;
transform: translate(-50%, -50%) rotate(45deg);
}
.polish {
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}
@keyframes blacksmithAppear {
0% { opacity: 0; transform: scale(0); }
100% { opacity: 1; transform: scale(1); }
}
@keyframes hammerStrike {
0% { transform: rotate(0deg); }
50% { transform: rotate(-45deg); }
100% { transform: rotate(0deg); }
}
@keyframes sparksFly {
0% { opacity: 1; transform: translate(0, 0) scale(1); }
100% { opacity: 0; transform: translate(20px, -30px) scale(0); }
}
@keyframes forgeGlow {
0% { width: 0; height: 0; opacity: 0; }
50% { width: 60px; height: 60px; opacity: 1; }
100% { width: 40px; height: 40px; opacity: 0.8; }
}
@keyframes swordForged {
0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); }
100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); }
}
@keyframes polishShine {
0% { left: -100%; opacity: 0; }
50% { opacity: 1; }
100% { left: 100%; opacity: 0; }
}
`}</style>
<button
className={`blacksmith-btn ${phase}`}
onClick={handleClick}
disabled={phase === 'animating'}
>
<span className="mr-2">🔨</span>
<span>{phase === 'success' ? 'Built!' : 'Build'}</span>
{phase === 'animating' && (
<>
<div className="forge-element blacksmith" style={{ animation: 'blacksmithAppear 0.3s ease-out forwards' }}></div>
<div className="forge-element hammer" style={{ animation: 'hammerStrike 0.2s ease-in-out 4' }}></div>
<div className="forge-element sparks" style={{ animation: 'sparksFly 0.8s ease-out 0.3s forwards' }}></div>
<div className="forge-element forge-glow" style={{ animation: 'forgeGlow 1s ease-in-out 1s forwards' }}></div>
<div className="forge-element sword" style={{ animation: 'swordForged 0.5s ease-out 1.5s forwards' }}></div>
<div className="forge-element polish" style={{ animation: 'polishShine 0.6s ease-in-out 2s forwards' }}></div>
</>
)}
</button>
</>
);
}
export default TinyBlacksmithButton;Vue
<template>
<div class="blacksmith-container">
<button
:class="['blacksmith-button', phase]"
@click="handleClick"
:disabled="phase === 'animating'"
>
<span class="anvil-icon">🔨</span>
<span class="button-text">{{ phase === 'success' ? 'Built!' : 'Build' }}</span>
<div v-if="phase === 'animating'" class="animation-elements">
<div class="forge-element blacksmith"></div>
<div class="forge-element hammer"></div>
<div class="forge-element sparks"></div>
<div class="forge-element forge-glow"></div>
<div class="forge-element sword"></div>
<div class="forge-element polish"></div>
</div>
</button>
</div>
</template>
<script setup>
import { ref } from 'vue';
const phase = ref('idle');
const handleClick = () => {
if (phase.value === 'animating') return;
phase.value = 'animating';
setTimeout(() => {
phase.value = 'success';
setTimeout(() => {
phase.value = 'idle';
}, 2000);
}, 2500);
};
</script>
<style scoped>
.blacksmith-container {
display: flex;
justify-content: center;
align-items: center;
padding: 2rem;
}
.blacksmith-button {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.blacksmith-button.animating {
background: linear-gradient(135deg, #b45309, #92400e);
}
.blacksmith-button.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.anvil-icon { margin-right: 0.5rem; }
.forge-element { position: absolute; opacity: 0; }
.blacksmith { bottom: 10px; left: 20%; width: 15px; height: 20px; background: #374151; border-radius: 2px; animation: blacksmithAppear 0.3s ease-out forwards; }
.hammer { bottom: 30px; left: 22%; width: 20px; height: 8px; background: #78350f; border-radius: 2px; transform-origin: left center; animation: hammerStrike 0.2s ease-in-out 4; }
.sparks { top: 50%; left: 30%; width: 5px; height: 5px; background: #fbbf24; border-radius: 50%; animation: sparksFly 0.8s ease-out 0.3s forwards; }
.forge-glow { top: 50%; left: 50%; width: 0; height: 0; background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent); border-radius: 50%; transform: translate(-50%, -50%); animation: forgeGlow 1s ease-in-out 1s forwards; }
.sword { top: 50%; left: 50%; width: 4px; height: 30px; background: linear-gradient(to bottom, #d1d5db, #9ca3af); border-radius: 2px; transform: translate(-50%, -50%) rotate(45deg); animation: swordForged 0.5s ease-out 1.5s forwards; }
.polish { top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent); animation: polishShine 0.6s ease-in-out 2s forwards; }
@keyframes blacksmithAppear { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }
@keyframes hammerStrike { 0% { transform: rotate(0deg); } 50% { transform: rotate(-45deg); } 100% { transform: rotate(0deg); } }
@keyframes sparksFly { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(20px, -30px) scale(0); } }
@keyframes forgeGlow { 0% { width: 0; height: 0; opacity: 0; } 50% { width: 60px; height: 60px; opacity: 1; } 100% { width: 40px; height: 40px; opacity: 0.8; } }
@keyframes swordForged { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); } }
@keyframes polishShine { 0% { left: -100%; opacity: 0; } 50% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.blacksmith-button:disabled { opacity: 0.7; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
.blacksmith-button.animating .forge-element {
animation: none !important;
}
}
</style>Svelte
<script>
let phase = 'idle';
function handleClick() {
if (phase === 'animating') return;
phase = 'animating';
setTimeout(() => {
phase = 'success';
setTimeout(() => {
phase = 'idle';
}, 2000);
}, 2500);
}
</script>
<div class="blacksmith-container">
<button class="blacksmith-button {phase}" on:click={handleClick} disabled={phase === 'animating'}>
<span class="anvil-icon">🔨</span>
<span class="button-text">{phase === 'success' ? 'Built!' : 'Build'}</span>
{#if phase === 'animating'}
<div class="forge-element blacksmith"></div>
<div class="forge-element hammer"></div>
<div class="forge-element sparks"></div>
<div class="forge-element forge-glow"></div>
<div class="forge-element sword"></div>
<div class="forge-element polish"></div>
{/if}
</button>
</div>
<style>
.blacksmith-container {
display: flex;
justify-content: center;
align-items: center;
padding: 2rem;
}
.blacksmith-button {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.blacksmith-button.animating {
background: linear-gradient(135deg, #b45309, #92400e);
}
.blacksmith-button.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.anvil-icon { margin-right: 0.5rem; }
.forge-element { position: absolute; opacity: 0; }
.blacksmith { bottom: 10px; left: 20%; width: 15px; height: 20px; background: #374151; border-radius: 2px; animation: blacksmithAppear 0.3s ease-out forwards; }
.hammer { bottom: 30px; left: 22%; width: 20px; height: 8px; background: #78350f; border-radius: 2px; transform-origin: left center; animation: hammerStrike 0.2s ease-in-out 4; }
.sparks { top: 50%; left: 30%; width: 5px; height: 5px; background: #fbbf24; border-radius: 50%; animation: sparksFly 0.8s ease-out 0.3s forwards; }
.forge-glow { top: 50%; left: 50%; width: 0; height: 0; background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent); border-radius: 50%; transform: translate(-50%, -50%); animation: forgeGlow 1s ease-in-out 1s forwards; }
.sword { top: 50%; left: 50%; width: 4px; height: 30px; background: linear-gradient(to bottom, #d1d5db, #9ca3af); border-radius: 2px; transform: translate(-50%, -50%) rotate(45deg); animation: swordForged 0.5s ease-out 1.5s forwards; }
.polish { top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent); animation: polishShine 0.6s ease-in-out 2s forwards; }
@keyframes blacksmithAppear { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }
@keyframes hammerStrike { 0% { transform: rotate(0deg); } 50% { transform: rotate(-45deg); } 100% { transform: rotate(0deg); } }
@keyframes sparksFly { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(20px, -30px) scale(0); } }
@keyframes forgeGlow { 0% { width: 0; height: 0; opacity: 0; } 50% { width: 60px; height: 60px; opacity: 1; } 100% { width: 40px; height: 40px; opacity: 0.8; } }
@keyframes swordForged { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); } }
@keyframes polishShine { 0% { left: -100%; opacity: 0; } 50% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.blacksmith-button:disabled { opacity: 0.7; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .blacksmith-button.animating .forge-element { animation: none !important; } }
</style>Angular
import { Component } from '@angular/core';
@Component({
selector: 'app-tiny-blacksmith-button',
template: `
<div class="blacksmith-container">
<button
[class]="'blacksmith-button ' + phase"
(click)="handleClick()"
[disabled]="phase === 'animating'"
>
<span class="anvil-icon">🔨</span>
<span class="button-text">{{ phase === 'success' ? 'Built!' : 'Build' }}</span>
<div *ngIf="phase === 'animating'" class="animation-elements">
<div class="forge-element blacksmith"></div>
<div class="forge-element hammer"></div>
<div class="forge-element sparks"></div>
<div class="forge-element forge-glow"></div>
<div class="forge-element sword"></div>
<div class="forge-element polish"></div>
</div>
</button>
</div>
`,
styles: [`
.blacksmith-container {
display: flex;
justify-content: center;
align-items: center;
padding: 2rem;
}
.blacksmith-button {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.blacksmith-button.animating {
background: linear-gradient(135deg, #b45309, #92400e);
}
.blacksmith-button.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.anvil-icon { margin-right: 0.5rem; }
.forge-element { position: absolute; opacity: 0; }
.blacksmith { bottom: 10px; left: 20%; width: 15px; height: 20px; background: #374151; border-radius: 2px; animation: blacksmithAppear 0.3s ease-out forwards; }
.hammer { bottom: 30px; left: 22%; width: 20px; height: 8px; background: #78350f; border-radius: 2px; transform-origin: left center; animation: hammerStrike 0.2s ease-in-out 4; }
.sparks { top: 50%; left: 30%; width: 5px; height: 5px; background: #fbbf24; border-radius: 50%; animation: sparksFly 0.8s ease-out 0.3s forwards; }
.forge-glow { top: 50%; left: 50%; width: 0; height: 0; background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent); border-radius: 50%; transform: translate(-50%, -50%); animation: forgeGlow 1s ease-in-out 1s forwards; }
.sword { top: 50%; left: 50%; width: 4px; height: 30px; background: linear-gradient(to bottom, #d1d5db, #9ca3af); border-radius: 2px; transform: translate(-50%, -50%) rotate(45deg); animation: swordForged 0.5s ease-out 1.5s forwards; }
.polish { top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent); animation: polishShine 0.6s ease-in-out 2s forwards; }
@keyframes blacksmithAppear { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }
@keyframes hammerStrike { 0% { transform: rotate(0deg); } 50% { transform: rotate(-45deg); } 100% { transform: rotate(0deg); } }
@keyframes sparksFly { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(20px, -30px) scale(0); } }
@keyframes forgeGlow { 0% { width: 0; height: 0; opacity: 0; } 50% { width: 60px; height: 60px; opacity: 1; } 100% { width: 40px; height: 40px; opacity: 0.8; } }
@keyframes swordForged { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); } }
@keyframes polishShine { 0% { left: -100%; opacity: 0; } 50% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.blacksmith-button:disabled { opacity: 0.7; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .blacksmith-button.animating .forge-element { animation: none !important; } }
`]
})
export class TinyBlacksmithButtonComponent {
phase = 'idle';
handleClick(): void {
if (this.phase === 'animating') return;
this.phase = 'animating';
setTimeout(() => {
this.phase = 'success';
setTimeout(() => {
this.phase = 'idle';
}, 2000);
}, 2500);
}
}LWC — HTML template
<template>
<div class="blacksmith-container">
<button class="blacksmith-button {buttonClass}" onclick={handleClick} disabled={isAnimating}>
<span class="anvil-icon">🔨</span>
<span class="button-text">{buttonText}</span>
<template if:true={isAnimating}>
<div class="forge-element blacksmith"></div>
<div class="forge-element hammer"></div>
<div class="forge-element sparks"></div>
<div class="forge-element forge-glow"></div>
<div class="forge-element sword"></div>
<div class="forge-element polish"></div>
</template>
</button>
</div>
</template>LWC — JavaScript
import { LightningElement, api } from 'lwc';
export default class TinyBlacksmithButton extends LightningElement {
@api label = 'Build';
phase = 'idle';
get isAnimating() {
return this.phase === 'animating';
}
get buttonText() {
return this.phase === 'success' ? 'Built!' : this.label;
}
get buttonClass() {
return `blacksmith-button ${this.phase}`;
}
handleClick() {
if (this.phase === 'animating') return;
this.phase = 'animating';
setTimeout(() => {
this.phase = 'success';
setTimeout(() => {
this.phase = 'idle';
}, 2000);
}, 2500);
}
}LWC — CSS
.blacksmith-container {
display: flex;
justify-content: center;
align-items: center;
padding: 2rem;
}
.blacksmith-button {
position: relative;
padding: 1rem 2rem;
background: linear-gradient(135deg, #92400e, #78350f);
border: none;
border-radius: 0.75rem;
color: #fef3c7;
font-weight: 700;
cursor: pointer;
overflow: hidden;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(146, 64, 14, 0.3);
}
.blacksmith-button:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(146, 64, 14, 0.4);
}
.blacksmith-button.animating {
background: linear-gradient(135deg, #b45309, #92400e);
}
.blacksmith-button.success {
background: linear-gradient(135deg, #10b981, #059669);
color: white;
}
.anvil-icon { margin-right: 0.5rem; }
.forge-element { position: absolute; opacity: 0; }
.blacksmith { bottom: 10px; left: 20%; width: 15px; height: 20px; background: #374151; border-radius: 2px; animation: blacksmithAppear 0.3s ease-out forwards; }
.hammer { bottom: 30px; left: 22%; width: 20px; height: 8px; background: #78350f; border-radius: 2px; transform-origin: left center; animation: hammerStrike 0.2s ease-in-out 4; }
.sparks { top: 50%; left: 30%; width: 5px; height: 5px; background: #fbbf24; border-radius: 50%; animation: sparksFly 0.8s ease-out 0.3s forwards; }
.forge-glow { top: 50%; left: 50%; width: 0; height: 0; background: radial-gradient(circle, rgba(251, 191, 36, 0.8), transparent); border-radius: 50%; transform: translate(-50%, -50%); animation: forgeGlow 1s ease-in-out 1s forwards; }
.sword { top: 50%; left: 50%; width: 4px; height: 30px; background: linear-gradient(to bottom, #d1d5db, #9ca3af); border-radius: 2px; transform: translate(-50%, -50%) rotate(45deg); animation: swordForged 0.5s ease-out 1.5s forwards; }
.polish { top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent); animation: polishShine 0.6s ease-in-out 2s forwards; }
@keyframes blacksmithAppear { 0% { opacity: 0; transform: scale(0); } 100% { opacity: 1; transform: scale(1); } }
@keyframes hammerStrike { 0% { transform: rotate(0deg); } 50% { transform: rotate(-45deg); } 100% { transform: rotate(0deg); } }
@keyframes sparksFly { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(20px, -30px) scale(0); } }
@keyframes forgeGlow { 0% { width: 0; height: 0; opacity: 0; } 50% { width: 60px; height: 60px; opacity: 1; } 100% { width: 40px; height: 40px; opacity: 0.8; } }
@keyframes swordForged { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scaleY(0); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scaleY(1); } }
@keyframes polishShine { 0% { left: -100%; opacity: 0; } 50% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
.blacksmith-button:disabled { opacity: 0.7; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .blacksmith-button.animating .forge-element { animation: none !important; } }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 Tiny Blacksmith fits
- Build tools
- Compile projects
- Generate code
- Create assets
Interaction states & animations
- Hammering
- Sparks
- Forging
- Polishing
- Complete
Topics
- #blacksmith
- #forge
- #build
- #hammer
- #sparks
- #craft
Accessibility notes
Animation is decorative. Button text remains readable. Respect reduced-motion preference.
Browser support
- All modern browsers