MeDo

AI検索バージェネレーター。

ユーザーが何を検索するかを説明すれば、MeDoがウィジェット全体を生成します — デバウンスされたクエリ、タイプアヘッドのドロップダウン、矢印キー操作、最近の検索、ローディングと結果なしの状態、フォーカス用のcmd+Kショートカットまで。

検索バー
検索バー

検索バーは視覚的フォーカスとDOMフォーカスが一致しない唯一の入力欄です

ページ上の他の要素は、フォーカスとハイライトが常に同じ場所にあります。タイプアヘッドではそれができません。入力を続けられるようにキャレットはテキストフィールドに留まる必要があり、その一方でハイライトは候補リストを下に移動します。正しいパターンはaria-activedescendantで、入力欄がDOMフォーカスを保持したまま、idでアクティブな候補を指し示します。代わりに実際のフォーカスをリストへ移す実装は入力を即座に壊してしまい、だからこそ手作りの検索バーの多くはマウスでは動くのにキーボードでは崩壊します。フィールドとリストを一つのウィジェットとして生成すれば、その関係はバグ報告後の後付け修正ではなく最初から結線されます。

6 個のテンプレート

生成できる 検索バー テンプレート

どのテンプレートもスクリーンショットではなく実際のプロンプトです。任意の AI エディタに貼り付けるか、MeDo で実行して React + Tailwind のコードを受け取れます。

BasicInput + Clear

Plain Search Field With Submit

No dropdown, no fetch — just a field that submits to a results page. Start here when the corpus is large enough that suggestions would be guesses rather than shortcuts.

Create a search field: a 40px-tall rounded input inside a real form with role="search", type="search" on the input, enterkeyhint="search" for mobile keyboards, and a visible label or aria-label since a magnifier icon is not an accessible name. Put a 16px magnifier on the left with aria-hidden, and a clear button on the right that appears only once there is text, is a real button with an accessible label, and returns focus to the input after clearing. Enter submits the raw query through the form so search still works with JavaScript disabled. Escape clears the field when it has text. Show a focus-visible ring on the wrapper, not the bare input, so the icon and field read as one control.

MeDoで試す
ComboboxTypeahead

Debounced Suggestions Listbox

The full combobox: debounce, listbox, aria-activedescendant. The critical rule is that DOM focus never leaves the input, or typing stops working the moment someone presses Arrow Down.

Create a typeahead search bar using the ARIA combobox pattern: aria-expanded, aria-controls and aria-activedescendant on the input, role="listbox" on the panel, role="option" with a unique id on each row. DOM focus must stay in the text field at all times — move the visual highlight by updating aria-activedescendant, never by focusing an option, or typing breaks. Debounce queries at 250ms and cancel in-flight requests so a slow earlier response cannot overwrite a newer one. Arrow Down and Up move the active option and wrap at the ends, Home and End jump to the first and last, Enter selects the active option or submits the raw query when none is active, Escape closes the panel and restores the typed text, and Tab closes and moves on rather than walking the options.

MeDoで試す
cmd+KCommand Palette

Modal Search Overlay

Search as primary navigation, opened from anywhere with cmd+K. It is a modal dialog, which means a focus trap and focus restoration — the part most palette clones skip.

Create a command-palette search overlay opened by cmd+K and ctrl+K: a centered dialog with a backdrop, using the native dialog element or role="dialog" with aria-modal="true". Trap focus inside it, place initial focus in the input, close on Escape and backdrop click, and return focus to the element that was focused before opening. Ignore the shortcut while the user is typing in another input or a contenteditable region. Inside, run the ARIA combobox pattern with aria-activedescendant, group results under headed sections such as Pages, Docs and Actions, and let Arrow Down and Up move across group boundaries while skipping the group headings. Show a visible cmd+K hint in the trigger and keyboard hints in the dialog footer.

MeDoで試す
StatesRecent + Empty

Search With Recent Queries and No-Results

Three panels, not one: recent searches on an empty query, skeleton rows in flight, a no-results row with a fallback. Leave any out and the dropdown flickers blank between keystrokes.

Create a search bar that renders three distinct dropdown states rather than one panel that empties. On an empty query, show up to five recent searches from localStorage under a Recent heading, each with a small remove button and a Clear all action. While a request is in flight, keep the previous results visible and overlay three skeleton rows, and swap the magnifier for an inline spinner rather than blanking the panel. On zero matches, show a no-results row naming the query plus a "Search everything" fallback action that submits the raw text. Announce the outcome in an aria-live="polite" region — "8 results available" or "No results" — debounced so intermediate counts are not read out. Arrow keys, Enter and Escape behave identically in all three states.

MeDoで試す
FiltersScoped Search

Search With Scope Chips and Filters

A scope chip inside the field narrows the query before it runs. Make Backspace on an empty query remove the chip — anything else and people are hunting for a tiny × with the mouse.

Create a scoped search bar: removable scope chips render inside the input wrapper to the left of the text caret, each a button with an accessible label such as "Remove filter: Invoices". Pressing Backspace with an empty query removes the last chip rather than doing nothing, and typing a known prefix followed by a colon converts it into a chip. Keep the chips out of the input value itself and send them as separate query parameters. Below the field, render filter pills that are toggle buttons with aria-pressed, and re-run the debounced query on every change. Preserve the caret position when a chip is added, keep the ARIA combobox wiring for the suggestion listbox, and reflect the active scope in the aria-live result-count announcement.

MeDoで試す
Media rowsRich Results

Suggestions With Thumbnails and Prices

Product and media rows where each suggestion carries an image, title and price. Reserve the thumbnail box explicitly, or every keystroke reflows the panel as images resolve.

Create a search bar with rich suggestion rows: each row is a role="option" containing a 40px thumbnail with explicit width and height attributes so the panel does not reflow as images load, a title with the matched substring bolded, and a secondary line with price or category. Because the row holds several elements, give each option an aria-label describing the whole row so a screen reader hears one coherent option rather than fragments. Cap the panel at 320px with internal scroll, and scroll the active option into view with block nearest as aria-activedescendant moves. Keep the last row a "See all results for <query>" action that submits the raw text. Highlight matches by wrapping the substring, never by injecting HTML from the response.

MeDoで試す

検索バー をカスタマイズする方法

デバウンス間隔を明示する

「入力をデバウンスして」ではなく「250msでデバウンスして」と伝えましょう。約150msを下回るとキー入力ごとにリクエストが飛び、400msを超えるとドロップダウンが壊れているように感じられます。キャンセル処理と組み合わせて、遅い古いレスポンスが新しいものを上書きしないようにしましょう。

3つの空状態を別々に説明する

クエリが空、リクエスト中、結果ゼロは、それぞれ別の画面です。1つ目には最近の検索、2つ目にはスピナーかスケルトン行、3つ目には結果なしの行とフォールバックアクションを依頼しましょう。どれかを省くと、パネルが白く点滅する結果になります。

Enterが送信か選択かを指定する

候補がハイライトされている場合、Enterはそれを選択すべきです。何もハイライトされていない場合、Enterは生のクエリを結果ページへ送信すべきです。両方の分岐を明記し、JavaScriptなしでも送信経路が機能するようrole="search"を持つ実際のformを依頼しましょう。

結果件数のアナウンスを依頼する

目の見えるユーザーはリストが増えるのを見られます。スクリーンリーダーのユーザーには「8件の結果があります」のように読み上げるaria-live="polite"領域が必要です。ライブ領域を明示的に依頼し、途中の件数を毎回読み上げないようこちらもデバウンスするよう頼みましょう。

検索バー コンポーネントを使うのは誰か

ドキュメントサイト

ページの上に開くcmd+K検索バー。ヒットをセクションごとにグループ化し、各タイトルの下に一致した行を表示し、直近5件のクエリを保持してうろ覚えのページに戻れるようにします。

Eコマースストア

各行にサムネイル、商品名、価格を並べた商品候補、その上にカテゴリーのショートカット、そして一番下に生のクエリを全結果ページへ送信する「...のすべての結果を見る」行。

ダッシュボードや管理ツール

顧客、請求書、設定をまたいで検索する一つのフィールド。結果は種類別にグループ化され、入力欄内のスコープチップで入力前に単一のエンティティへ絞り込めます。

コンテンツ・メディアライブラリ

横に並ぶフィルターピル付きの幅広い検索バー、クエリ実行中のスケルトン行、そして空のパネルを見せる代わりにスペル修正を提案する結果なし状態。

サイト種別ごとの 検索バー パターン

同じ 検索バー コンポーネントを、掲載するサイトの種類に合わせて調整します。

01 / 06

Documentation Search

A cmd+K palette that groups hits by section and shows the matching line under each title, since a page title alone rarely tells a reader whether the answer is on it. Keep the last five queries — docs search is mostly people returning to a page they half remember.

検索バー のスタイルとバリアント

ページ全体のトーンに合うバリアントを選び、そのまま生成します。

01 / 06

Inline Field Search

A permanent bordered input in the header or page body. The most discoverable option and the only one that works without JavaScript, since a real form with role="search" submits on Enter regardless. Give the wrapper the focus ring so the icon and field read as one control.

React・Next.js・Vue・Svelte での 検索バー

React、Next.js、Vue 3、SvelteKit、Astro、素の HTML — 同じ 検索バー を 6 通りの方法で組み込めます。

01 / 06

React Search Bar

Track the active index as a number and derive aria-activedescendant from it — that is the entire highlight mechanism, with no focus moves. Abort the previous fetch in the effect cleanup so a slow response cannot land after a newer one.

src/components/SearchBar.tsx

const [active, setActive] = useState(-1)
const debounced = useDebounce(query, 250)

<input
  type="search"
  role="combobox"
  aria-expanded={open}
  aria-controls="search-listbox"
  aria-activedescendant={active >= 0 ? `opt-${active}` : undefined}
  onKeyDown={onArrowKeys}
/>

検索バー をプロジェクトに追加する方法

検索バー テンプレートを選んで本番に載せるまでの 4 ステップ。

01~30s

Pick a Search Pattern

Decide whether you need suggestions at all. A plain field posting to a results page is often the honest answer; reach for the typeahead or the cmd+K palette only when search is a primary navigation path.

02~10s

Copy the Prompt

Take the prompt into MeDo, Lovable, Bolt, v0 or Cursor, then set two numbers: the debounce interval and how many suggestions the panel shows. Name what is being searched too, since that decides how a result row is shaped.

03~1min

Generate and Refine

You get React + Tailwind back with a live preview. Follow up in plain English — "add recent searches", "group results by type", "announce the result count politely" — rather than rewriting the keydown handler.

04~2min

Connect Your Index and Ship

Point the query at your real endpoint, then test with the keyboard only: type, Arrow Down, Enter, Escape. If typing stops working after Arrow Down, focus was moved into the list and the highlight needs to go back to aria-activedescendant.

検索バーに関するよくある質問

AIで検索バーを生成するには?

何を検索するのか、候補はどこから取得するのか、どの状態が必要か(最近の検索、ローディング、結果なし)を説明してください。MeDoは入力欄、候補ドロップダウン、デバウンスされたクエリ処理、キーバインドを一つのコンポーネントとして生成します。後から自分で結線しなければならない裸のテキストフィールドではありません。

検索バーとオートコンプリートの違いは?

検索バーは自由入力のクエリを送信し、候補はショートカットとして扱うため、一致がない語を入力しても有効です。オートコンプリートは値をリストに制約するため、候補を選んだときにだけ値が確定します。この違いはマークアップを変えます。検索バーはrole="search"を持つform内に置き、制約付きオートコンプリートはフォーム値に紐づくコンボボックスになります。

AIはアクセシブルな検索バーを生成できますか?

はい、パターンを名前で指定すれば可能です。MeDoはARIAコンボボックスパターンを実装し、入力欄にaria-expanded、aria-controls、aria-activedescendant、パネルにrole="listbox"とrole="option"、結果件数用のpoliteなライブ領域を用意します。フォーカスは常にテキストフィールドに留まり、それが入力と矢印キーの併用を成立させます。

検索ドロップダウンのキーボード操作はどうあるべきですか?

下矢印で最初の候補に移動しリストを下っていき、上矢印で戻って生のクエリにフォーカスを返せるようにし、Enterでハイライト中の項目を選択、Escapeでパネルを閉じて入力内容を復元します。長いリストではHomeとEndも便利な追加です。Tabは候補を辿るのではなく、パネルを閉じて次へ移動すべきです。

入力欄にtype="search"を使うべきですか?

はい。一部のプラットフォームでブラウザ標準のクリア機能が得られ、支援技術に意図を伝え、モバイルキーボードでのenterkeyhint="search"とも組み合わせられます。スクリプトが失敗してもクエリが送信されるようrole="search"を持つ実際のformで包み、虫眼鏡アイコンだけではアクセシブルな名前にならないため入力欄にラベルかaria-labelを付けてください。

検索バーにcmd+Kショートカットは必要ですか?

ドキュメント、ダッシュボード、開発者ツールなど、検索が主要なナビゲーション手段である場所では役立ちます。cmd+Kとctrl+Kの両方をバインドし、ユーザーが別の入力欄で入力中はショートカットを無視し、発見しやすいようフィールド内にヒントを表示しましょう。MeDoへのプロンプトで言及すれば、リスナーと可視のヒントが一緒に生成されます。