Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Highlight for React and Tailwind

Highlight search terms within text.

shadcn.io is a component library for building accessible web applications.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/highlight.json

Usage

import { Highlight } from "@/registry/react/components/highlight";
<Highlight
  query="amet"
  text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
/>

Examples

Multiple

Pass an array of strings to the query prop to highlight multiple substrings.

Search Query

Use the Highlight component to highlight search query results.

With Squiggle

Use a custom decoration like a wavy underline for a fancier highlight effect.

Custom Style

Use the className prop to customize the style of the highlighted text.

API Reference

Highlight

PropTypeDefault
querystring | string[]required
textstringrequired
ignoreCasebooleanfalse
exactMatchbooleanfalse
classNamestring""

For a complete list of props, see the Ark UI documentation.