DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerContainer QueryDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTA ModalDate PickerDialogFieldFieldsetFile UploaderIconButtonInputLoading StatesMarqueeMenuNotificationsNumber InputPaginationPin InputPopoverProgress IndicatorsPrompt ModalRadioRatingSelectSliderSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFormat Relative TimeFrameHighlightJSON Tree ViewLocalePortalPresenceShowSwapsplitPropsTheme

Highlight

Highlight text with query

  • npm
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page

Usage

The Highlight component takes a text prop containing the full text and a query prop specifying the text to highlight. It then renders the text with highlighted portions wrapped in <mark> tags.

Loading example...

Multiple Queries

You can highlight multiple terms by passing an array of strings to the query prop.

Loading example...

Case Sensitivity

By default, the highlighting is case-sensitive. Use the ignoreCase prop to make it case-insensitive.

Loading example...

Match All

By default, the Highlight component matches the first occurrence of the query. To highlight all occurrences of the query, set the matchAll prop to true.

Loading example...

Exact Match

By default, the Highlight component matches partial words. Use the exactMatch prop to only highlight whole words that match the query exactly.

Loading example...

API Reference

Props

PropTypeRequiredDefaultDescription
querystring | string[]trueundefinedThe query to highlight in the text
textstringtrueundefinedThe text to highlight
exactMatchbooleanfalseundefinedWhether to match whole words only
ignoreCasebooleanfalseundefinedWhether to ignore case while matching
matchAllbooleanfalseundefinedWhether to match multiple instances of the query

Customization

The Highlight component wraps matched text in <mark> tags. Pass a className (or class in Solid/Svelte/Vue) to style the highlighted portions.

<Highlight
  className="highlight-mark"
  query="component"
  text="Ark UI is a headless component library for building accessible web applications."
/>

On this page

  • Usage
    • Multiple Queries
    • Case Sensitivity
    • Match All
    • Exact Match
  • API Reference
  • Customization
Edit this page on Github
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt
The quick brown Fox jumps over the lazy Dog.

Match All

The quick brown fox jumps over the lazy fox.

Match First Occurrence Only

The quick brown fox jumps over the lazy fox.

Without exactMatch (highlights partial matches):

The cat is in the category. A cat-like creature.

With exactMatch (highlights whole words only):

The cat is in the category. A cat-like creature.