panelui

Command Dock

Component

About

A small button that opens into a field, with the answer arriving under it a row at a time.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Command Dock to your project and fits it to your theme.

Code

How Command Dock is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

'use client';

import { FileTextIcon, SearchIcon } from 'lucide-react';
import { useRef, useState } from 'react';
import { CommandDock } from '@/components/ui/panel-command-dock';
/** What a search of some meeting notes might turn up. */
const NOTES = [
  { title: 'Pricing review', where: 'Notes from 3 March' },
  { title: 'What we decided about trials', where: 'Notes from 19 February' },
  { title: 'Questions for finance', where: 'Notes from 11 February' },
  { title: 'Draft of the pricing page', where: 'Shared by Imani' },
];

export default function CommandDockFind() {
  const [found, setFound] = useState<typeof NOTES>([]);
  const [busy, setBusy] = useState(false);
  const timers = useRef<number[]>([]);

  // Stands in for a search that answers a row at a time.
  const find = () => {
    timers.current.forEach((timer) => window.clearTimeout(timer));
    setFound([]);
    setBusy(true);
    timers.current = NOTES.map((note, index) =>
      window.setTimeout(() => {
        setFound((current) => [...current, note]);
        if (index === NOTES.length - 1) setBusy(false);
      }, 500 + index * 450)
    );
  };

  return (
    <CommandDock onSubmit={find} busy={busy} closedWidth="10.5rem" className="min-h-72 items-start">
      <CommandDock.Trigger>
        <SearchIcon />
        Search the notes
      </CommandDock.Trigger>
      <CommandDock.Panel>
        <CommandDock.Input placeholder="Try: pricing" aria-label="Search the notes" />
        <CommandDock.Results label="Notes found">
          {found.map((note) => (
            <CommandDock.Row key={note.title}>
              <FileTextIcon />
              <CommandDock.RowTitle>{note.title}</CommandDock.RowTitle>
              <CommandDock.RowMeta>{note.where}</CommandDock.RowMeta>
            </CommandDock.Row>
          ))}
          {busy ? <CommandDock.Status>Reading the notes</CommandDock.Status> : null}
        </CommandDock.Results>
      </CommandDock.Panel>
    </CommandDock>
  );
}

Dependencies

More by panelui

View all
  • Spinner

    Spinner

    8
  • Flow

    Flow

    4
  • Hex Chart

    Hex Chart

    2
  • Treemap Chart

    Treemap Chart

    1
  • Soundwave

    Soundwave

    1
  • Share

    Share

    1
  • Scatter Chart

    Scatter Chart

    1
  • Pyramid Chart

    Pyramid Chart

    1