← Prompt Lab

3D Barrel Command Palette (⌘K)

Pure CSS Scroll-Driven 3D List for cmdk & shadcn/ui Command
SaaS & AI · Scroll 3D1.0 KB CSS0 copies
SHARE
05 / PLAYGROUND3D Barrel Command Palette (⌘K)
BRAND COLORS
Fullscreen ↗

A Raycast & Linear-grade ⌘K Command Palette where command rows roll smoothly across a 3D cylindrical barrel using native CSS view() timelines — works directly on [cmdk-item] with ↑↓ keyboard scrolling and 0 KB scroll JS.

cmdk Readyshadcn CommandCSS Scroll 3D0 KB Scroll JS
/* 1) Paste once in globals.css — upgrades ANY existing cmdk / shadcn CommandList (0 KB JS)
@keyframes cmd-barrel {
  0%   { opacity: 0.14; transform: perspective(680px) translateY(14px) rotateX(-54deg) scale(0.84); }
  20%  { opacity: 0.72; transform: perspective(680px) translateY(3px) rotateX(-22deg) scale(0.95); }
  40%, 60% { opacity: 1; transform: perspective(680px) translateY(0) rotateX(0deg) scale(1); }
  80%  { opacity: 0.72; transform: perspective(680px) translateY(-3px) rotateX(22deg) scale(0.95); }
  100% { opacity: 0.14; transform: perspective(680px) translateY(-14px) rotateX(54deg) scale(0.84); }
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .cmdk-barrel [cmdk-item],
    .cmdk-barrel [cmdk-group-heading] {
      animation: cmd-barrel linear both;
      animation-timeline: view(block);
      animation-range: cover 0% cover 100%;
    }
  }
}
*/

// 2) Drop-in React + Tailwind + shadcn/ui Command (cmdk) component
'use client'
import { useEffect, useState } from 'react'
import {
  CommandDialog, CommandEmpty, CommandGroup, CommandInput,
  CommandItem, CommandList, CommandShortcut,
} from '@/components/ui/command'
import { Sparkles, Rocket, Terminal, GitBranch, ShieldCheck, Cloud } from 'lucide-react'

const COMMANDS = [
  { group: 'AI Agents', id: 'copilot', label: 'Ask AI Copilot', kbd: '⌘J', Icon: Sparkles },
  { group: 'AI Agents', id: 'review', label: 'Run AI Security Review', kbd: '⇧R', Icon: ShieldCheck },
  { group: 'Deploy', id: 'preview', label: 'Deploy Preview Branch', kbd: '⇧D', Icon: Rocket },
  { group: 'Deploy', id: 'logs', label: 'Tail Edge Function Logs', kbd: 'G L', Icon: Terminal },
  { group: 'Deploy', id: 'purge', label: 'Purge CDN Tag Cache', kbd: '⇧C', Icon: Cloud },
  { group: 'Workspace', id: 'branch', label: 'Switch Git Branch', kbd: '⌘B', Icon: GitBranch },
]

export function BarrelCommandPalette({ onRun }: { onRun?: (id: string) => void }) {
  const [open, setOpen] = useState(false)

  useEffect(() => {
    const onKeyDown = (e: KeyboardEvent) => {
      if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
        e.preventDefault()
        setOpen((v) => !v)
      }
    }
    window.addEventListener('keydown', onKeyDown)
    return () => window.removeEventListener('keydown', onKeyDown)
  }, [])

  return (
    <>
      <button
        type="button"
        onClick={() => setOpen(true)}
        className="inline-flex items-center gap-2 rounded-xl border border-white/15 bg-[#0f1320] px-3.5 py-2 text-xs font-medium text-slate-200 shadow-lg"
      >
        <span className="h-2 w-2 rounded-full" style={{ background: '#8b5cf6' }} />
        Command Palette
        <kbd className="rounded border border-white/15 bg-white/5 px-1.5 py-0.5 font-mono text-[10px]">⌘K</kbd>
      </button>

      <CommandDialog open={open} onOpenChange={setOpen}>
        <CommandInput placeholder="Type a command or search AI actions…" />
        <div className="relative h-[280px] overflow-hidden">
          {/* Center focal rail */}
          <div
            aria-hidden="true"
            className="pointer-events-none absolute inset-x-3 top-1/2 z-10 h-[52px] -translate-y-1/2 rounded-xl border-y"
            style={{ backgroundColor: '#8b5cf616', borderColor: '#38bdf855' }}
          />
          <CommandList className="cmdk-barrel h-full max-h-none overflow-y-auto px-3 py-11 [mask-image:linear-gradient(to_bottom,transparent,black_14%,black_86%,transparent)]">
            <CommandEmpty>No matching commands.</CommandEmpty>
            {['AI Agents', 'Deploy', 'Workspace'].map((group) => (
              <CommandGroup key={group} heading={group}>
                {COMMANDS.filter((c) => c.group === group).map(({ id, label, kbd, Icon }) => (
                  <CommandItem
                    key={id}
                    onSelect={() => {
                      onRun?.(id)
                      setOpen(false)
                    }}
                    className="mb-1.5 h-12 rounded-xl border border-white/10 px-3"
                  >
                    <Icon className="mr-2.5 size-4" style={{ color: '#38bdf8' }} />
                    <span>{label}</span>
                    <CommandShortcut>{kbd}</CommandShortcut>
                  </CommandItem>
                ))}
              </CommandGroup>
            ))}
          </CommandList>
        </div>
      </CommandDialog>
    </>
  )
}

WHY THIS WORKS IN PRODUCTION

  • Targets [cmdk-item] & [cmdk-group-heading] directly — 12 lines of CSS upgrades any existing shadcn Command
  • Arrow-key ↑↓ navigation scrolls items into center focus, naturally rolling the 3D CSS barrel
  • Live command execution toast, fuzzy search, scope filters, 34°/54°/72° curve presets & Auto-Roll
  • Baseline Oct 2026 pure CSS view() with automatic @supports & prefers-reduced-motion fallback

DROP-IN SPECS // WEB & MOBILE FIT

UI SLOTScroll & 3D CSS
BEST USE CASESaaS ⌘K Command Menus, AI Copilot Launchers & Developer Tool Palettes
IDEAL PLACEMENTGlobal ⌘K Dialog (shadcn/ui CommandDialog / cmdk / Radix Dialog)
BUNDLE SIZE1.0 KB CSS
DEPENDENCIESZero (CSS view() · cmdk / shadcn ready)
MOBILE / TOUCHKeyboard ↑↓ + Touch Scroll
GPU WEIGHTLight · 60fps