This component no longer exists. It was in cubby-ui’s manifest when we first indexed it and is not there now — the registry served its inventory on 2026-08-10 and this item was not on it. The install command below will fail. It is kept here because a tutorial somewhere still tells people to run it.
highlightText
cubby-ui/highlight-textRemovedUtility
A utility function for highlight text.
Install it
npx shadcn@latest add https://cubby-ui.dev/r/highlight-text.jsonSource
1import * as React from "react";23export function highlightText(text: string, query: string): React.ReactNode {4 const trimmed = query.trim();5 if (!trimmed) {6 return text;7 }89 const limited = trimmed.slice(0, 100);10 const escaped = limited.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");11 const regex = new RegExp(`(${escaped})`, "gi");1213 return text.split(regex).map((part, idx) =>14 part.toLowerCase() === limited.toLowerCase() ? (15 <mark key={idx} className="text-primary bg-transparent font-bold">16 {part}17 </mark>18 ) : (19 part20 ),21 );22}
