Treasure Map
A compass spins wildly then an X marks the spot on a treasure map
Treasure Map
by FreeCsStyles Dev's
AnimatedAdventure
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#treasure#map#compass#discover#adventure#pirate#x-marks#gold
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/treasure-map.
<iframe src="/embed/treasure-map" sandbox="allow-scripts" loading="lazy" title="Treasure Map" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Treasure Map, 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-map"><span class="compass">🧭</span><span class="text">Discover</span><span class="x-mark">❌</span></button>CSS
.btn-map{width:160px;height:50px;border-radius:12px;border:2px dashed #92400e;background:#d97706;color:#451a03;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-map .compass{position:absolute;left:10px;font-size:20px;opacity:0}.btn-map .x-mark{position:absolute;right:20px;font-size:20px;color:#dc2626;opacity:0;transform:scale(0)}.btn-map.is-discovering{width:180px;background:#fcd34d}.btn-map.is-discovering .compass{opacity:1;animation:spin-compass 1s ease-in-out}.btn-map.is-found{background:#fbbf24;border-style:solid}.btn-map.is-found .x-mark{opacity:1;transform:scale(1.2);transition:.4s cubic-bezier(.5,2,.5,1)}@keyframes spin-compass{0%{transform:rotate(0deg)}100%{transform:rotate(720deg)}}Tailwind CSS
<button class="w-[160px] h-[50px] rounded-xl border-2 border-dashed border-amber-800 bg-amber-600 text-amber-950 font-bold cursor-pointer relative flex items-center justify-center overflow-hidden transition-all duration-[400ms] font-sans"><span class="relative z-10">🧭 Discover</span></button>React
import { useState } from 'react';
export function TreasureMap() {
const [phase, setPhase] = useState('idle');
const handleClick = () => {
if (phase !== 'idle') return;
setPhase('discovering');
setTimeout(() => setPhase('found'), 1200);
setTimeout(() => setPhase('idle'), 3500);
};
return (
<button onClick={handleClick} disabled={phase !== 'idle'}
style={{ width: phase === 'discovering' ? 180 : 160, height: 50, borderRadius: 12, border: phase === 'found' ? '2px solid #fbbf24' : '2px dashed #92400e', background: phase === 'found' ? '#fbbf24' : phase === 'discovering' ? '#fcd34d' : '#d97706', color: '#451a03', 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' ? '🧭 Discover' : phase === 'discovering' ? 'Searching...' : 'Found! 👑'}</span>
</button>
);
}Vue
<template>
<button class="btn-map" :class="phase" @click="handleClick" :disabled="phase!=='idle'">
<span class="compass">🧭</span>
<span class="text">{{ phase==='idle' ? 'Discover' : phase==='discovering' ? 'Searching...' : 'Found!' }}</span>
<span class="x-mark">❌</span>
</button>
</template>
<script setup>
import { ref } from 'vue';
const phase = ref('idle');
function handleClick() {
if (phase.value !== 'idle') return;
phase.value = 'discovering';
setTimeout(() => phase.value = 'found', 1200);
setTimeout(() => phase.value = 'idle', 3500);
}
</script>Svelte
<script>
let phase = 'idle';
function handleClick() { if (phase !== 'idle') return; phase = 'discovering'; setTimeout(() => phase = 'found', 1200); setTimeout(() => phase = 'idle', 3500); }
</script>
<button class="btn-map" class:is-found={phase==='found'} on:click={handleClick} disabled={phase!=='idle'}>
<span class="compass">🧭</span>
<span class="text">{phase==='idle' ? 'Discover' : phase==='discovering' ? 'Searching...' : 'Found!'}</span>
<span class="x-mark">❌</span>
</button>Angular
import { Component } from '@angular/core';
@Component({
selector: 'app-treasure-map',
template: `<button class="btn-map" [class.is-discovering]="phase==='discovering'" [class.is-found]="phase==='found'" (click)="handleClick()" [disabled]="phase!=='idle'"><span class="compass">🧭</span><span class="text">{{ phase==='idle' ? 'Discover' : phase==='discovering' ? 'Searching...' : 'Found!' }}</span><span class="x-mark">❌</span></button>`,
styles: [`.btn-map{width:160px;height:50px;border-radius:12px;border:2px dashed #92400e;background:#d97706;color:#451a03;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}.btn-map.is-found{background:#fbbf24;border-style:solid}`]
})
export class TreasureMapComponent { phase='idle';handleClick(){if(this.phase!=='idle')return;this.phase='discovering';setTimeout(()=>this.phase='found',1200);setTimeout(()=>this.phase='idle',3500);}}LWC — HTML template
<template><button class="btn-map" onclick={handleClick} disabled={disabled}><span>{label}</span></button></template>LWC — JavaScript
import { LightningElement } from 'lwc';
export default class TreasureMap extends LightningElement {
phase = 'idle';
get disabled() { return this.phase !== 'idle'; }
get label() { return this.phase==='idle'?'🧭 Discover':this.phase==='discovering'?'Searching...':'Found! 👑'; }
handleClick() { if(this.phase!=='idle')return;this.phase='discovering';setTimeout(()=>this.phase='found',1200);setTimeout(()=>this.phase='idle',3500); }
}LWC — CSS
.btn-map{width:160px;height:50px;border-radius:12px;border:2px dashed #92400e;background:#d97706;color:#451a03;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:all .4s}.btn-map.is-found{background:#fbbf24;border-style:solid}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 Treasure Map fits
- Discovery
- Search Actions
- Finding
- Rewards
- Gamified UI
Interaction states & animations
- Compass Spin
- X Reveal
- Discovery
Topics
- #treasure
- #map
- #compass
- #discover
- #adventure
- #pirate
- #x-marks
- #gold
Accessibility notes
Animation is decorative. Button text remains readable. Respect reduced-motion preference.
Browser support
- All modern browsers