Skip to content

Butterfly Transformation

A caterpillar crawls to center, forms a cocoon, then emerges as a butterfly that flies away

Butterfly Transformation

by FreeCsStyles Dev's

AnimatedNature
🌐🎨⚛️💚🅰️🔥☁️
#butterfly#caterpillar#transformation#cocoon#metamorphosis#nature#upgrade#growth

Embed this component

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

<iframe src="/embed/butterfly-transformation" sandbox="allow-scripts" loading="lazy" title="Butterfly Transformation" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Butterfly Transformation, 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-bug"><span class="critter" id="bugIcon">🐛</span><span class="text">Upgrade</span></button>
CSS
.btn-bug{width:160px;height:50px;border-radius:12px;border:none;background:#4ade80;color:#064e3b;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-bug .critter{position:absolute;left:15px;font-size:20px;transition:.5s}.btn-bug .text{margin-left:25px;transition:.3s}.btn-bug.is-crawling .critter{left:70px;animation:crawl .4s infinite alternate}.btn-bug.is-crawling .text{opacity:0}.btn-bug.is-cocoon{background:#a7f3d0}.btn-bug.is-cocoon .critter{transform:scale(1.2);animation:none}.btn-bug.is-butterfly{background:#34d399}.btn-bug.is-butterfly .critter{transform:translate(50px,-40px) scale(1.5);opacity:0;transition:1.5s ease-in}@keyframes crawl{0%{transform:translateY(0)}100%{transform:translateY(-3px) rotate(10deg)}}
Tailwind CSS
<button class="w-[160px] h-[50px] rounded-xl border-none bg-green-400 text-emerald-900 font-bold cursor-pointer relative flex items-center justify-center overflow-hidden transition-all duration-[400ms] font-sans"><span class="relative z-10">🐛 Upgrade</span></button>
React
import { useState } from 'react';
export function ButterflyTransformation() {
  const [phase, setPhase] = useState('idle');
  const handleClick = () => {
    if (phase !== 'idle') return;
    setPhase('crawling');
    setTimeout(() => setPhase('cocoon'), 800);
    setTimeout(() => setPhase('butterfly'), 1600);
    setTimeout(() => setPhase('idle'), 4000);
  };
  return (
    <button onClick={handleClick} disabled={phase !== 'idle'}
      style={{ width: 160, height: 50, borderRadius: 12, border: 'none', background: phase === 'cocoon' ? '#a7f3d0' : phase === 'butterfly' ? '#34d399' : '#4ade80', color: '#064e3b', 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' ? '🐛 Upgrade' : phase === 'butterfly' ? '🦋 Upgraded!' : ''}</span>
    </button>
  );
}
Vue
<template>
  <button class="btn-bug" :class="phase" @click="handleClick" :disabled="phase!=='idle'">
    <span class="critter">{{ critter }}</span>
    <span class="text">{{ phase==='idle' ? 'Upgrade' : phase==='butterfly' ? 'Upgraded!' : '' }}</span>
  </button>
</template>
<script setup>
import { ref, computed } from 'vue';
const phase = ref('idle');
const critter = computed(() => phase.value==='cocoon'?'🥚':phase.value==='butterfly'?'🦋':'🐛');
function handleClick() {
  if (phase.value !== 'idle') return;
  phase.value = 'crawling';
  setTimeout(() => phase.value = 'cocoon', 800);
  setTimeout(() => phase.value = 'butterfly', 1600);
  setTimeout(() => phase.value = 'idle', 4000);
}
</script>
Svelte
<script>
  let phase = 'idle';
  $: critter = phase==='cocoon'?'🥚':phase==='butterfly'?'🦋':'🐛';
  function handleClick() { if (phase !== 'idle') return; phase = 'crawling'; setTimeout(() => phase = 'cocoon', 800); setTimeout(() => phase = 'butterfly', 1600); setTimeout(() => phase = 'idle', 4000); }
</script>
<button class="btn-bug" class:is-butterfly={phase==='butterfly'} on:click={handleClick} disabled={phase!=='idle'}>
  <span class="critter">{critter}</span>
  <span class="text">{phase==='idle' ? 'Upgrade' : phase==='butterfly' ? 'Upgraded!' : ''}</span>
</button>
Angular
import { Component } from '@angular/core';
@Component({
  selector: 'app-butterfly-transformation',
  template: `<button class="btn-bug" [class.is-crawling]="phase==='crawling'" [class.is-cocoon]="phase==='cocoon'" [class.is-butterfly]="phase==='butterfly'" (click)="handleClick()" [disabled]="phase!=='idle'"><span class="critter">{{ critter }}</span><span class="text">{{ phase==='idle' ? 'Upgrade' : phase==='butterfly' ? 'Upgraded!' : '' }}</span></button>`,
  styles: [`.btn-bug{width:160px;height:50px;border-radius:12px;border:none;background:#4ade80;color:#064e3b;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}.btn-bug.is-cocoon{background:#a7f3d0}.btn-bug.is-butterfly{background:#34d399}`]
})
export class ButterflyTransformationComponent { phase='idle';get critter(){return this.phase==='cocoon'?'🥚':this.phase==='butterfly'?'🦋':'🐛'}handleClick(){if(this.phase!=='idle')return;this.phase='crawling';setTimeout(()=>this.phase='cocoon',800);setTimeout(()=>this.phase='butterfly',1600);setTimeout(()=>this.phase='idle',4000);}}
LWC — HTML template
<template><button class="btn-bug" onclick={handleClick} disabled={disabled}><span>{label}</span></button></template>
LWC — JavaScript
import { LightningElement } from 'lwc';
export default class ButterflyTransformation extends LightningElement {
  phase = 'idle';
  get disabled() { return this.phase !== 'idle'; }
  get label() { const p=this.phase; return p==='idle'?'🐛 Upgrade':p==='butterfly'?'🦋 Upgraded!':''; }
  handleClick() { if(this.phase!=='idle')return;this.phase='crawling';setTimeout(()=>this.phase='cocoon',800);setTimeout(()=>this.phase='butterfly',1600);setTimeout(()=>this.phase='idle',4000); }
}
LWC — CSS
.btn-bug{width:160px;height:50px;border-radius:12px;border:none;background:#4ade80;color:#064e3b;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:all .4s}.btn-bug.is-cocoon{background:#a7f3d0}.btn-bug.is-butterfly{background:#34d399}
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 Butterfly Transformation fits

  • Upgrade Actions
  • Transformation
  • Growth
  • Evolution
  • Metamorphosis

Interaction states & animations

  • Caterpillar Crawl
  • Cocoon
  • Butterfly Fly
  • Metamorphosis

Topics

  • #butterfly
  • #caterpillar
  • #transformation
  • #cocoon
  • #metamorphosis
  • #nature
  • #upgrade
  • #growth

Accessibility notes

Animation is decorative. Button text remains readable. Respect reduced-motion preference.

Browser support

  • All modern browsers