Treasure Compass
Navigate button with compass spinning, needle settling, glowing path, and destination reached animation
Treasure Compass
by FreeCsStyles Dev's
AnimatedStorybook
🌐HTML/CSS🎨Tailwind⚛️React💚Vue🅰️Angular🔥Svelte☁️LWC
#compass#treasure#navigate#discover#path#glow
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/treasure-compass.
<iframe src="/embed/treasure-compass" sandbox="allow-scripts" loading="lazy" title="Treasure Compass" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Treasure Compass, 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-compass"><span class="compass">🧭</span><span class="text">Navigate</span><div class="glow-path"></div></button>CSS
.btn-compass{width:180px;height:60px;border-radius:12px;border:2px solid #d97706;background:linear-gradient(135deg,#f59e0b,#d97706);color:#fff;font-size:16px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;gap:8px;overflow:hidden;transition:all .4s;font-family:system-ui,sans-serif;z-index:1}.btn-compass .compass{position:relative;z-index:2;transition:all .3s}.btn-compass .text{position:relative;z-index:2;transition:all .3s}.btn-compass .glow-path{position:absolute;bottom:0;left:50%;width:4px;height:0;background:linear-gradient(0deg,#fbbf24,transparent);transition:all .8s ease;z-index:1}.btn-compass.is-navigating .compass{animation:compass-spin 1.5s ease-in-out}.btn-compass.is-navigating .glow-path{height:100%;left:50%;transform:translateX(-50%);width:4px;background:linear-gradient(0deg,#fbbf24,transparent)}.btn-compass.is-navigating .text{opacity:0;transform:translateY(-10px)}.btn-compass.is-found{background:linear-gradient(135deg,#84cc16,#65a30d);border-color:#65a30d;box-shadow:0 0 30px rgba(132,204,22,.5)}.btn-compass.is-found .compass{animation:compass-settle .5s ease-out}.btn-compass.is-found .glow-path{height:100%;left:50%;transform:translateX(-50%);width:8px;background:linear-gradient(0deg,#a3e635,transparent);box-shadow:0 0 20px rgba(163,230,53,.6)}.btn-compass.is-found .text{opacity:1;transform:translateY(0)}@keyframes compass-spin{0%{transform:rotate(0deg)}30%{transform:rotate(180deg)}60%{transform:rotate(350deg)}80%{transform:rotate(340deg)}100%{transform:rotate(360deg)}}@keyframes compass-settle{0%{transform:rotate(0deg) scale(1.3)}50%{transform:rotate(10deg) scale(1.3)}100%{transform:rotate(0deg) scale(1)}}Tailwind CSS
<button class="relative w-[180px] h-[60px] rounded-xl border-2 border-amber-600 bg-gradient-to-br from-amber-500 to-amber-600 text-white font-bold text-base flex items-center justify-center gap-2 overflow-hidden transition-all duration-300 hover:shadow-lg hover:shadow-amber-500/50"><span class="relative z-10">🧭 Navigate</span></button>React
import { useState } from 'react';
export function TreasureCompassButton() {
const [phase, setPhase] = useState('idle');
const handleClick = () => {
if (phase !== 'idle') return;
setPhase('navigating');
setTimeout(() => setPhase('found'), 2000);
setTimeout(() => setPhase('idle'), 4500);
};
const bgClass = phase === 'found'
? 'linear-gradient(135deg, #84cc16, #65a30d)'
: 'linear-gradient(135deg, #f59e0b, #d97706)';
return (
<button onClick={handleClick} disabled={phase !== 'idle'}
style={{
width: 180, height: 60, borderRadius: 12,
border: phase === 'found' ? '2px solid #65a30d' : '2px solid #d97706',
background: bgClass, color: '#fff',
fontSize: 16, fontWeight: 'bold', cursor: 'pointer', position: 'relative',
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
overflow: 'hidden', fontFamily: 'system-ui,sans-serif',
boxShadow: phase === 'found' ? '0 0 30px rgba(132,204,22,0.5)' : 'none',
transition: 'all 0.4s'
}}>
<span style={{ position: 'relative', zIndex: 10 }}>
{phase === 'idle' ? '🧭 Navigate' : phase === 'found' ? '📍 Found!' : '🧭'}
</span>
{phase !== 'idle' && (
<div style={{ position: 'absolute', bottom: 0, left: '50%', width: phase === 'found' ? 8 : 4, height: '100%', background: `linear-gradient(0deg, ${phase === 'found' ? '#a3e635' : '#fbbf24'}, transparent)`, transform: 'translateX(-50%)', transition: 'all 0.8s', zIndex: 5 }} />
)}
</button>
);
}Vue
<template>
<button class="btn-compass" :class="phaseClass" @click="handleClick" :disabled="phase !== 'idle'">
<span class="compass">{{ phase === 'idle' ? '🧭' : phase === 'found' ? '📍' : '🧭' }}</span>
<span class="text">{{ phase === 'idle' ? 'Navigate' : phase === 'found' ? 'Found!' : '' }}</span>
<div class="glow-path"></div>
</button>
</template>
<script setup>
import { ref, computed } from 'vue';
const phase = ref('idle');
const phaseClass = computed(() => `is-${phase.value}`);
function handleClick() {
if (phase.value !== 'idle') return;
phase.value = 'navigating';
setTimeout(() => phase.value = 'found', 2000);
setTimeout(() => phase.value = 'idle', 4500);
}
</script>Svelte
<script>
let phase = 'idle';
function handleClick() {
if (phase !== 'idle') return;
phase = 'navigating';
setTimeout(() => phase = 'found', 2000);
setTimeout(() => phase = 'idle', 4500);
}
</script>
<button class="btn-compass" class:is-found={phase==='found'} on:click={handleClick} disabled={phase !== 'idle'}>
<span>{phase === 'idle' ? '🧭 Navigate' : phase === 'found' ? '📍 Found!' : '🧭'}</span>
</button>Angular
import { Component } from '@angular/core';
@Component({
selector: 'app-compass-button',
template: `<button class="btn-compass" [class.is-navigating]="phase==='navigating'" [class.is-found]="phase==='found'" (click)="handleClick()" [disabled]="phase!=='idle'"><span>{{ phase==='idle' ? '🧭 Navigate' : phase==='found' ? '📍 Found!' : '🧭' }}</span></button>`,
styles: [`.btn-compass{width:180px;height:60px;border-radius:12px;border:2px solid #d97706;background:linear-gradient(135deg,#f59e0b,#d97706);color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:hidden;transition:all .4s}.btn-compass.is-found{background:linear-gradient(135deg,#84cc16,#65a30d);border-color:#65a30d;box-shadow:0 0 30px rgba(132,204,22,.5)}`]
})
export class CompassButtonComponent {
phase = 'idle';
handleClick() {
if (this.phase !== 'idle') return;
this.phase = 'navigating';
setTimeout(() => this.phase = 'found', 2000);
setTimeout(() => this.phase = 'idle', 4500);
}
}LWC — HTML template
<template><button class="btn-compass" onclick={handleClick} disabled={disabled}><span>{label}</span></button></template>LWC — JavaScript
import { LightningElement } from 'lwc';
export default class TreasureCompassButton extends LightningElement {
phase = 'idle';
get disabled() { return this.phase !== 'idle'; }
get label() { return this.phase === 'idle' ? '🧭 Navigate' : this.phase === 'found' ? '📍 Found!' : '🧭'; }
handleClick() {
if (this.phase !== 'idle') return;
this.phase = 'navigating';
setTimeout(() => { this.phase = 'found'; }, 2000);
setTimeout(() => { this.phase = 'idle'; }, 4500);
}
}LWC — CSS
.btn-compass{width:180px;height:60px;border-radius:12px;border:2px solid #d97706;background:linear-gradient(135deg,#f59e0b,#d97706);color:#fff;font-size:16px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;overflow:hidden;transition:all .4s}.btn-compass.is-found{background:linear-gradient(135deg,#84cc16,#65a30d);border-color:#65a30d;box-shadow:0 0 30px rgba(132,204,22,.5)}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 Compass fits
- Navigation
- Wayfinding
- Discovery
- Exploration
Interaction states & animations
- Compass Spin
- Needle Settle
- Glow Path
- Destination
Topics
- #compass
- #treasure
- #navigate
- #discover
- #path
- #glow
Accessibility notes
Animation is decorative. Button text remains readable. Respect reduced-motion preference.
Browser support
- All modern browsers