Search modal

Search across the workspace in a modal: the query, result tabs, and results to move through by keyboard.

Open full screen

A panel opens over any screen and keeps its own look in every direction: it has no direction of its own.

npx wideset add block-modal-search

Import the default export from @/blocks/wideset/modal-search. The files below are relative to your project's source directory.

Installed with this block
  • avatar
  • block-styles
  • button
  • modal
  • tabs
  • text-input
  • utils
blocks/wideset/modal-search/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { Button } from '@/components/ui/wideset/button/Button';
import { useState } from 'react';

import { index, QUERY, workspace } from './data';
import { SearchModal } from './search-modal';

/** Search modal: search across the workspace, here over an empty page that reopens it. */
export default function ModalSearchBlock() {
  const [open, setOpen] = useState(true);

  return (
    <div className="ws-block-utility bg-ws-static-foreground flex h-dvh items-center justify-center">
      <Button variant="secondary" preset="border" onClick={() => setOpen(true)}>
        Open search
      </Button>
      <SearchModal
        index={index}
        workspace={workspace}
        initialQuery={QUERY}
        open={open}
        onOpenChange={setOpen}
        // A starting point has nowhere to go: opening a result closes the search.
        onOpenResult={() => setOpen(false)}
      />
    </div>
  );
}