Componentmedia0.46 KB gzipZero dependencies

HighlightText

Highlights query matches inside text with accent background and animated reveal

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add highlight-text

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { HighlightText } from "@/components/ui/highlight-text" <HighlightText text="The quick brown fox" query="fox" />

Source code

highlight-text.tsx + 1 helper

Zero 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 />
PropTypeDescription
textstringThe text content to highlight within
querystringThe search term to highlight