Search Match
Marks the part of a result that matches the search, on a light navy tint, keeping the text's own size and colour.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
import { HighlightMatch, SearchMatch } from "@leap-crm/design-system";Playground
Change a prop and the component follows. Its code is under Props.
Ada Hartley
Props
text
query
Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use HighlightMatch with the result's text and the searched query in search results and pickers, like Ada in Ada Hartley. It marks every case-insensitive match. |
| Do | Use SearchMatch by hand when you already know which part matched, like a range the server returns. |
| Don't | Use it to emphasise words in text nobody searched, like a key phrase in a note. The tint means the text matched a search. |
| Don't | Use it to point at an item someone was taken to from a notification or a link. Use Highlight. |
Props
SearchMatch takes every prop of a <mark>.
HighlightMatch
| Prop | Type | Default | Description |
|---|---|---|---|
| text * | string | — | The text to show, like a contact's name. |
| query * | string | — | What was searched for. Every case-insensitive match is marked. |
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
SearchMatch
No props of its own.
Code
What the playground shows, ready to copy.
import { HighlightMatch } from "@leap-crm/design-system";
<HighlightMatch text="Ada Hartley" query="hart" />By hand
Ada Hartley
What the examples share
The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.
import { useState } from "react";
import { HighlightMatch, SearchMatch } from "@leap-crm/design-system";
const people = [
"Ada Hartley",
"Adam Nguyen",
"Jane Citizen",
"Kanada Pty Ltd",
] as const;
function Searching() {
const [query, setQuery] = useState("ada");
return (
<div className="flex w-72 flex-col gap-2">
<label className="text-small text-neutral-text-muted flex flex-col gap-1">
Search
<input
value={query}
onChange={event => setQuery(event.target.value)}
className="border-neutral-border text-neutral-text focus-visible:border-focus-border focus-visible:shadow-focus h-9 rounded-md border px-3 text-base outline-none"
/>
</label>
<ul className="m-0 flex list-none flex-col gap-1 p-0 text-base">
{people.map(person => (
<li key={person}>
<HighlightMatch text={person} query={query} />
</li>
))}
</ul>
</div>
);
}




