Skip to content

Detective Search

Magnifying glass grows legs, detective walks around using a flashlight, finds the target and raises hand, then results appear in a popup

Embed this component

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

<iframe src="/embed/detective-search" sandbox="allow-scripts" loading="lazy" title="Detective Search" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Detective Search, 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-detective"><div class="detective"><div class="hat">🎩</div><div class="body">🕵️</div><div class="legs"><div class="leg left"></div><div class="leg right"></div></div><div class="flashlight"><div class="beam"></div><span class="light-icon">🔦</span></div></div><div class="target"><span>🎯</span></div><div class="results-popup"><div class="result-line"></div><div class="result-line short"></div><div class="result-line"></div></div><span class="btn-text">Search</span></button>
CSS
.btn-detective{width:180px;height:56px;border-radius:14px;border:none;background:linear-gradient(135deg,#1e3a5f,#1a2e4a);color:#fff;font-size:15px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;font-family:system-ui,-apple-system,sans-serif;box-shadow:0 4px 15px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.05)}.btn-detective:hover{box-shadow:0 6px 20px rgba(0,0,0,.4)}.btn-detective .detective{position:absolute;display:flex;flex-direction:column;align-items:center;z-index:4;opacity:0;transition:all .5s cubic-bezier(.34,1.56,.64,1)}.btn-detective .hat{font-size:12px;line-height:1;margin-bottom:-4px;z-index:2}.btn-detective .body{font-size:20px;line-height:1;transition:transform .3s}.btn-detective .legs{display:flex;gap:6px;margin-top:-2px}.btn-detective .leg{width:3px;height:10px;background:#94a3b8;border-radius:2px;transform-origin:top}.btn-detective .flashlight{position:absolute;right:-30px;top:50%;transform:translateY(-50%);display:flex;flex-direction:column;align-items:center;opacity:0;transition:all .4s}.btn-detective .flashlight .light-icon{font-size:14px}.btn-detective .flashlight .beam{width:0;height:0;border-left:15px solid rgba(255,255,200,.3);border-top:4px solid transparent;border-bottom:4px solid transparent;margin-bottom:-2px;margin-right:-8px;opacity:0;transition:all .3s}.btn-detective .target{position:absolute;right:15px;font-size:16px;opacity:0;transform:scale(0);transition:all .4s cubic-bezier(.34,1.56,.64,1);z-index:3}.btn-detective .results-popup{position:absolute;top:-5px;right:10px;background:#0f172a;border:1px solid #334155;border-radius:6px;padding:4px 8px;display:flex;flex-direction:column;gap:2px;opacity:0;transform:translateY(10px) scale(.8);transition:all .3s;z-index:5}.btn-detective .result-line{height:2px;background:#475569;border-radius:1px;width:30px}.btn-detective .result-line.short{width:20px}.btn-detective .btn-text{z-index:5;transition:all .3s;position:relative}.btn-detective.is-walking .detective{opacity:1;animation:detective-walk .6s ease-in-out infinite}.btn-detective.is-walking .detective .body{animation:body-wobble .3s ease-in-out infinite}.btn-detective.is-walking .leg.left{animation:leg-swing-l .3s ease-in-out infinite}.btn-detective.is-walking .leg.right{animation:leg-swing-r .3s ease-in-out infinite}.btn-detective.is-walking .flashlight{opacity:1;right:-25px;animation:flashlight-sweep .8s ease-in-out infinite alternate}.btn-detective.is-walking .flashlight .beam{opacity:1;animation:beam-flicker .4s ease-in-out infinite alternate}.btn-detective.is-walking .btn-text{opacity:0}.btn-detective.is-walking .target{opacity:1;animation:target-pulse .5s ease-in-out infinite}.btn-detective.is-found .detective{opacity:1;transform:translateX(10px)}.btn-detective.is-found .detective .body{animation:raise-hand .4s ease-out forwards}.btn-detective.is-found .results-popup{opacity:1;transform:translateY(0) scale(1)}.btn-detective.is-found .target{opacity:1;transform:scale(1.2)}.btn-detective.is-done{background:linear-gradient(135deg,#1e3a5f,#0f2940);box-shadow:0 4px 20px rgba(59,130,246,.2)}.btn-detective.is-done .btn-text{color:#60a5fa}@keyframes detective-walk{0%,100%{transform:translateX(0)}25%{transform:translateX(-8px)}50%{transform:translateX(0)}75%{transform:translateX(8px)}}@keyframes body-wobble{0%,100%{transform:rotate(0) translateY(0)}50%{transform:rotate(-3deg) translateY(-2px)}}@keyframes leg-swing-l{0%,100%{transform:rotate(-15deg)}50%{transform:rotate(15deg)}}@keyframes leg-swing-r{0%,100%{transform:rotate(15deg)}50%{transform:rotate(-15deg)}}@keyframes flashlight-sweep{0%{transform:translateY(-50%) rotate(-15deg)}100%{transform:translateY(-50%) rotate(15deg)}}@keyframes beam-flicker{0%{opacity:.4;border-left-color:rgba(255,255,200,.2)}100%{opacity:1;border-left-color:rgba(255,255,200,.5)}}@keyframes target-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}@keyframes raise-hand{0%{transform:rotate(0)}50%{transform:rotate(-10deg) translateY(-3px)}100%{transform:rotate(0) translateY(-2px)}}
Tailwind CSS
<button class="w-[180px] h-[56px] rounded-[14px] border-none bg-gradient-to-br from-[#1e3a5f] to-[#1a2e4a] text-white font-bold text-[15px] cursor-pointer relative flex items-center justify-center overflow-hidden font-sans shadow-lg"><span class="relative z-10">🔍 Search</span></button>
React
import { useState } from 'react';
export function DetectiveSearch() {
  const [phase, setPhase] = useState('idle');
  const handleClick = () => {
    if (phase !== 'idle') return;
    setPhase('walking');
    setTimeout(() => setPhase('found'), 2500);
    setTimeout(() => setPhase('done'), 3500);
    setTimeout(() => setPhase('idle'), 5000);
  };
  return (
    <button onClick={handleClick} disabled={phase !== 'idle'}
      style={{ width: 180, height: 56, borderRadius: 14, border: 'none', background: 'linear-gradient(135deg, #1e3a5f, #1a2e4a)', color: phase === 'done' ? '#60a5fa' : '#fff', fontSize: 15, fontWeight: 'bold', cursor: 'pointer', position: 'relative', display: 'flex', alignItems: 'center', justifyContent: 'center', overflow: 'hidden', fontFamily: 'system-ui,sans-serif', transition: 'all 0.3s', boxShadow: '0 4px 15px rgba(0,0,0,0.3)' }}>
      <span style={{ zIndex: 5, opacity: phase === 'walking' || phase === 'found' ? 0 : 1, transition: 'all 0.3s' }}>
        {phase === 'done' ? '🔍 Found!' : '🔍 Search'}
      </span>
      {(phase === 'walking' || phase === 'found') && (
        <span style={{ position: 'absolute', fontSize: 24, zIndex: 4, animation: 'detective-walk 0.6s ease-in-out infinite' }}>🕵️</span>
      )}
      {phase === 'found' && (
        <span style={{ position: 'absolute', right: 15, fontSize: 16, zIndex: 3, animation: 'target-pulse 0.5s ease-in-out infinite' }}>🎯</span>
      )}
    </button>
  );
}
Vue
<template>
  <button class="btn-detective" :class="phase" @click="handleClick" :disabled="phase!=='idle'">
    <div class="detective">
      <div class="hat">🎩</div>
      <div class="body">🕵️</div>
      <div class="legs"><div class="leg left"></div><div class="leg right"></div></div>
    </div>
    <div class="flashlight"><div class="beam"></div><span class="light-icon">🔦</span></div>
    <div class="target"><span>🎯</span></div>
    <div class="results-popup"><div class="result-line"></div><div class="result-line short"></div><div class="result-line"></div></div>
    <span class="btn-text">{{ label }}</span>
  </button>
</template>
<script setup>
import { ref, computed } from 'vue';
const phase = ref('idle');
const label = computed(() => ({idle:'🔍 Search',walking:'',found:'',done:'🔍 Found!'}[phase.value]));
function handleClick() {
  if (phase.value !== 'idle') return;
  phase.value = 'walking';
  setTimeout(() => phase.value = 'found', 2500);
  setTimeout(() => phase.value = 'done', 3500);
  setTimeout(() => phase.value = 'idle', 5000);
}
</script>
Svelte
<script>
  let phase = 'idle';
  $: label = ({idle:'🔍 Search',walking:'',found:'',done:'🔍 Found!'})[phase];
  function handleClick() {
    if (phase !== 'idle') return;
    phase = 'walking';
    setTimeout(() => phase = 'found', 2500);
    setTimeout(() => phase = 'done', 3500);
    setTimeout(() => phase = 'idle', 5000);
  }
</script>
<button class="btn-detective" class:is-walking={phase==='walking'} class:is-found={phase==='found'} class:is-done={phase==='done'} on:click={handleClick} disabled={phase!=='idle'}>
  <div class="detective"><div class="hat">🎩</div><div class="body">🕵️</div><div class="legs"><div class="leg left"></div><div class="leg right"></div></div></div>
  <div class="flashlight"><div class="beam"></div><span class="light-icon">🔦</span></div>
  <div class="target"><span>🎯</span></div>
  <div class="results-popup"><div class="result-line"></div><div class="result-line short"></div><div class="result-line"></div></div>
  <span class="btn-text">{label}</span>
</button>
Angular
import { Component } from '@angular/core';
@Component({
  selector: 'app-detective-search',
  template: `<button class="btn-detective" [class.is-walking]="phase==='walking'" [class.is-found]="phase==='found'" [class.is-done]="phase==='done'" (click)="handleClick()" [disabled]="phase!=='idle'"><div class="detective"><div class="hat">🎩</div><div class="body">🕵️</div><div class="legs"><div class="leg left"></div><div class="leg right"></div></div></div><div class="flashlight"><div class="beam"></div><span class="light-icon">🔦</span></div><div class="target"><span>🎯</span></div><div class="results-popup"><div class="result-line"></div><div class="result-line short"></div><div class="result-line"></div></div><span class="btn-text">{{ label }}</span></button>`,
  styles: [`.btn-detective{width:180px;height:56px;border-radius:14px;border:none;background:linear-gradient(135deg,#1e3a5f,#1a2e4a);color:#fff;font-size:15px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}.btn-detective .detective{position:absolute;display:flex;flex-direction:column;align-items:center;z-index:4;opacity:0;transition:all .5s}.btn-detective.is-walking .detective{opacity:1;animation:detective-walk .6s ease-in-out infinite}.btn-detective.is-walking .btn-text{opacity:0}.btn-detective.is-done{background:linear-gradient(135deg,#1e3a5f,#0f2940)}.btn-detective.is-done .btn-text{color:#60a5fa}@keyframes detective-walk{0%,100%{transform:translateX(0)}25%{transform:translateX(-8px)}75%{transform:translateX(8px)}}`]
})
export class DetectiveSearchComponent { phase='idle'; get label() { return {idle:'🔍 Search',walking:'',found:'',done:'🔍 Found!'}[this.phase]; } handleClick() { if(this.phase!=='idle')return;this.phase='walking';setTimeout(()=>this.phase='found',2500);setTimeout(()=>this.phase='done',3500);setTimeout(()=>this.phase='idle',5000); } }
LWC — HTML template
<template><button class="btn-detective" onclick={handleClick} disabled={disabled}><span class="btn-text">{label}</span></button></template>
LWC — JavaScript
import { LightningElement } from 'lwc';
export default class DetectiveSearch extends LightningElement {
  phase = 'idle';
  get disabled() { return this.phase !== 'idle'; }
  get label() { return {idle:'🔍 Search',walking:'',found:'',done:'🔍 Found!'}[this.phase]; }
  handleClick() { if(this.phase!=='idle')return;this.phase='walking';setTimeout(()=>this.phase='found',2500);setTimeout(()=>this.phase='done',3500);setTimeout(()=>this.phase='idle',5000); }
}
LWC — CSS
.btn-detective{width:180px;height:56px;border-radius:14px;border:none;background:linear-gradient(135deg,#1e3a5f,#1a2e4a);color:#fff;font-size:15px;font-weight:700;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:all .3s}.btn-detective.is-done{background:linear-gradient(135deg,#1e3a5f,#0f2940)}.btn-detective.is-done .btn-text{color:#60a5fa}
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 Detective Search fits

  • Search
  • Find
  • Investigate
  • Lookup

Interaction states & animations

  • Walk
  • Flashlight
  • Find
  • Results Reveal

Topics

  • #detective
  • #search
  • #magnifying
  • #flashlight
  • #investigate
  • #find

Accessibility notes

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

Browser support

  • All modern browsers