Image Asset Command Card
Command palette as an inline card, not a modal: a searchable list of image assets with thumbnails and an open marker, copy-link and open-full-size actions, and a footer of keyboard shortcut hints with a live status.
"use client"
import * as React from "react"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandShortcut,
} from "@/components/ui/command"
import { Kbd, KbdGroup } from "@/components/ui/kbd"
import { Separator } from "@/components/ui/separator"
// The copy: change text here, not in the markup.
const COPY = {
title: "Command",
body: "Pick a work, then copy its link or open it full size.",
placeholder: "Search the registry…",
empty: "Nothing under that name.",
works: "Works",
actions: "On the open work",
open: "Open",
copied: "Link copied",
failed: "Copy failed",
} as const
const works = [
{
name: "Fire",
line: "Fields",
src: "https://01orbital.dev/currents/fire.png",
},
{
name: "Moss",
line: "Fields",
src: "https://01orbital.dev/currents/moss.png",
},
{
name: "Delta",
line: "Currents",
src: "https://01orbital.dev/currents/delta.png",
},
{
name: "Tide",
line: "Fields",
src: "https://01orbital.dev/currents/tide.png",
},
]
const actions = [
{ id: "copy", label: "Copy image link" },
{ id: "open", label: "Open full size" },
] as const
const keys = [
["↑ ↓", "Move"],
["↵", "Run"],
] as const
// the row highlight: a quiet wash with small corners, not a pill
export default function ImageAssetCommandCard() {
const [open, setOpen] = React.useState("Tide")
const [status, setStatus] = React.useState("")
async function run(id: (typeof actions)[number]["id"]) {
const src = works.find((w) => w.name === open)?.src
if (!src) return
if (id === "open") {
window.open(src, "_blank", "noopener")
return
}
try {
await navigator.clipboard.writeText(src)
setStatus(`${COPY.copied} · ${open}`)
} catch {
setStatus(COPY.failed)
}
}
return (
<Card className="mx-auto w-full max-w-lg gap-4">
<CardHeader>
<CardTitle>{COPY.title}</CardTitle>
<CardDescription>{COPY.body}</CardDescription>
</CardHeader>
<CardContent className="px-0.5">
<Command>
<CommandInput placeholder={COPY.placeholder} />
<CommandList className="max-h-80 scroll-fade pt-3">
<CommandEmpty>{COPY.empty}</CommandEmpty>
<CommandGroup heading={COPY.works}>
{works.map((w) => (
<CommandItem
key={w.name}
value={w.name}
className="font-normal data-selected:bg-muted/60"
onSelect={() => {
setOpen(w.name)
setStatus(`${COPY.open} · ${w.name}`)
}}
>
<img
src={w.src}
alt=""
loading="lazy"
className="size-6 shrink-0 rounded-xs object-cover"
/>
{w.name}
{/* The work's series, not a key combo: tracking-normal
undoes the wide letter-spacing meant for keys. */}
<CommandShortcut className="flex items-center gap-2 font-mono tracking-normal">
{w.name === open ? (
<>
<span
aria-hidden="true"
className="size-1.5 rounded-full bg-art-accent"
/>
{COPY.open}
</>
) : (
w.line
)}
</CommandShortcut>
</CommandItem>
))}
</CommandGroup>
<CommandGroup heading={COPY.actions}>
{actions.map((a) => (
<CommandItem
key={a.id}
value={a.label}
className="font-normal data-selected:bg-muted/60"
onSelect={() => void run(a.id)}
>
{a.label}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</CardContent>
<CardFooter className="flex-col items-stretch gap-3">
<Separator />
<footer className="flex items-baseline justify-between gap-4">
<ul role="list" className="flex items-center gap-6">
{keys.map(([key, label]) => (
<li key={label} className="flex items-center gap-2">
<KbdGroup>
{key.split(" ").map((part) => (
<Kbd key={part}>{part}</Kbd>
))}
</KbdGroup>
<span className="font-mono text-xs text-muted-foreground">
{label}
</span>
</li>
))}
</ul>
<span
role="status"
className="truncate font-mono text-xs text-muted-foreground"
>
{status}
</span>
</footer>
</CardFooter>
</Card>
)
}
Installation
npx shadcn@latest add @01orbital/image-asset-command-cardMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/dialog/image-asset-command-card/index.tsx: change them there, not in the markup.
Built from
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on