Componentmedia0.46 KB gzipZero dependencies
HighlightText
Highlights query matches inside text with accent background and animated reveal
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add highlight-textOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { HighlightText } from "@/components/ui/highlight-text" <HighlightText text="The quick brown fox" query="fox" />Source code
highlight-text.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxhighlight-text.tsx74 lines
import * as React from "react";import { cn } from "./lib/utils"; export type HighlightTextProps = { text: string; query: string;}; const HighlightText = ({ text, query }: HighlightTextProps) => { if (!query) { return ( <div className={cn( "font-mono text-sm", "animate-[fade-in-up_0.3s_ease-out_both]", "motion-reduce:animate-none" )} >Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { HighlightText } from "@/components/ui/highlight-text"; <HighlightText />| Prop | Type | Description |
|---|---|---|
| text | string | The text content to highlight within |
| query | string | The search term to highlight |