Back to Shark UI

Highlight

docs/utilities/highlight

latest6.3 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Highlight

Copy Markdown

Highlight search terms within text.

Docs

PreviewCode

Shark UI is a component library for building accessible web applications.

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/highlight

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.

PreviewCode

With the Highlight component, you can spotlight, emphasize and accentuate words.

Search Query#

Use the Highlight component to highlight search query results.

PreviewCode

Search result for: spot

  • Spotlight bulb
  • Spot cleaner
  • Spot ceiling

With Squiggle#

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

PreviewCode

Endless scale, powered by real humans.

Custom Style#

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

PreviewCode

With the Highlight component, you can spotlight words.

API Reference#

Highlight#

PropTypeDefault
query`stringstring[]`
textstringrequired
ignoreCasebooleanfalse
exactMatchbooleanfalse
classNamestring""

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

[

Previous page

Format ](/docs/utilities/format)[

Next page

Hitbox ](/docs/utilities/hitbox)

On This Page

InstallationUsageExamplesMultipleSearch QueryWith SquiggleCustom StyleAPI ReferenceHighlight