TextHighlight


目录

Highlights occurrences of a given string within another string of text. Wraps each match with a <mark> tag which provides browser default styling.

Usage

Pass in the text and the highlight string to be matched against.

In the example below, the string Gutenberg would be highlighted twice.

import { TextHighlight } from '@wordpress/components';

const MyTextHighlight = () => (
    <TextHighlight
        text="Why do we like Gutenberg? Because Gutenberg is the best!"
        highlight="Gutenberg"
    />
);

Props

The component accepts the following props.

highlight: string

text: string

The string of text to be tested for occurrences of then given highlight.


版本号 #2
由 壳壳虫 创建于 2026-10-31 18:14:55 UTC
由 壳壳虫 更新于 2026-10-31 18:14:56 UTC