Skip to main content

Chat

ConversationFind

The find bar for a conversation: a box with previous and next buttons, the match's place ("2 of 5") and a close button. Enter and Shift+Enter in the box step to the next and previous match, F3 and Shift+F3 and Cmd+G or Ctrl+G with Shift do the same from anywhere on the page while the bar is open, and Escape closes it and puts focus back where it was before the bar opened. A step never moves focus out of the box; the list brings the current match into view. The place is a polite status announced once per change. The bar draws and counts nothing itself: pass what a MessageList's onFindMatches reports as count and current, and query and current back to its find prop.

Ana
Lunch at noon?
You
Nothing to add.
Ana
Café for lunch, or LUNCH out
You
Back for lunch at one

Install

Hand it to your agent
Add ConversationFind from Ouro UI to this app. Read https://ui.ouroboros.bot/docs/conversation-find.md first and follow it.

Or by hand. Once per app, with Tailwind CSS v4 and an @/* path alias (Ouro HX is built on Base UI, so --base base; skip -t in an existing app):

npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823

Then the component (Installing):

npx shadcn@latest add ourostack/ouro-ui/conversation-find#v1.3.823
import { ConversationFind } from "@/components/ouro/conversation-find/conversation-find";

Paths use shadcn's default @/ alias; the CLI rewrites them to yours.

Example

<ConversationFind label="Find in conversation" query={query} onQueryChange={setQuery} count={report.count} current={report.current} onCurrentChange={setCurrent} onClose={() => setOpen(false)} />

Usage

Use MessageList's own find for the highlighting and the count; use ConversationFind for the box that drives it.

Use instead when

  • Use TextField type="search" instead when the search is for a list of things and not for the text of one conversation.

Props

Type: ConversationFindProps.

className
Type: string
Layout only: margins, width, grid placement (mt-2, w-full). Appearance classes warn in development.
closeLabel
Type: string
Default: "Close find"
The name of the close button, as visually hidden text.
count (required)
Type: number
How many matches there are: the count a MessageList reports through onFindMatches.
current (required)
Type: number | null
The index of the current match, or null when the list has not found one: pass it to the list's find={{ current }} too.
label (required)
Type: string
What the bar finds in, for screen readers: "Find in conversation". It names the bar's region and its box. Required, so both have a name.
nextLabel
Type: string
Default: "Next match"
The name of the next button, as visually hidden text.
noMatchesLabel
Type: string
Default: "No matches"
What the bar and its announcement say for a search without a match.
onClose (required)
Type: () => void
Called when the reader closes the bar with Escape or its close button. Put focus back and stop passing find to the list.
onCurrentChange (required)
Type: (current: number) => void
Called with the match a step lands on (Enter, F3, the buttons). It wraps round past either end.
onQueryChange (required)
Type: (query: string) => void
Called with what the reader typed.
partial
Type: boolean
Default: false
True while more matches may lie in history not loaded yet (the report's partial): the count reads as a lower bound, "2 of 5+".
placeholder
Type: string
Default: "Find"
The name of the box's text, as a placeholder.
previousLabel
Type: string
Default: "Previous match"
The name of the previous button, as visually hidden text.
query (required)
Type: string
What is typed in the box. The bar is controlled: keep it in state and pass it to the list's find={{ query }}.
ref
Type: Ref<HTMLDivElement>
The bar's <div>.
resultLabel
Type: ((current: number, count: number) => string)
What the bar and its announcement say for the current match: (2, 5) is "2 of 5". Translate it with your app.

Native attributes

Also accepts the attributes in React's HTMLAttributes (id, aria-*, event handlers), passed to the rendered element, except those named on this page.

Don't use

These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.

  • onNext: Not a prop. Ouro UI uses onCurrentChange.
  • onSearch: Not a prop. Ouro UI uses onQueryChange.
  • value: Not a prop. Ouro UI uses query: <ConversationFind query={query} />.

className is for layout only

Pass margins, width and grid placement (mt-4, w-full, col-span-2).

Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (hover:, sm:) and any ! are removed, it starts with bg-, text-, border-, rounded-, shadow-, font-, ring-, from-, via-, to-, fill- or stroke-, or is border, rounded, shadow or ring, or has a dark: variant. Text wrapping, overflow and table layout classes (text-wrap, text-ellipsis, border-collapse) are layout and do not warn.

Alignment classes (text-center) warn too: set alignment on a parent element.