# Highlight URL: https://ark-ui.com/docs/utilities/highlight Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/utilities/highlight.mdx Used to emphasize specific words or phrases within a larger body of text. --- ## 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 `` tags. **Example: basic** ```ripple import { Highlight } from 'ark-ripple/highlight'; import styles from 'styles/highlight.module.css'; export component Basic() {

} ``` ### Dynamic Query Control the `query` prop with state to create an interactive search highlighting experience. **Example: dynamic-query** ```ripple import { Highlight } from 'ark-ripple/highlight'; import { track } from 'ripple'; import field from 'styles/field.module.css'; import styles from 'styles/highlight.module.css'; export component DynamicQuery() { const query = track('component');
{ @query = (e.target as HTMLInputElement).value; }} />

} ``` ### Multiple Queries You can highlight multiple terms by passing an array of strings to the `query` prop. **Example: multiple** ```ripple import { Highlight } from 'ark-ripple/highlight'; import styles from 'styles/highlight.module.css'; export component Multiple() {

} ``` ### Case Sensitivity By default, the highlighting is case-sensitive. Use the `ignoreCase` prop to make it case-insensitive. **Example: ignore-case** ```ripple import { Highlight } from 'ark-ripple/highlight'; import styles from 'styles/highlight.module.css'; export component IgnoreCase() {

} ``` ### 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`. **Example: match-all** ```ripple import { Highlight } from 'ark-ripple/highlight'; import styles from 'styles/highlight.module.css'; export component MatchAll() {
{'Match All'}

{'Match First Only'}

} ``` ### Exact Match By default, the Highlight component matches partial words. Use the `exactMatch` prop to only highlight whole words that match the query exactly. **Example: exact-match** ```ripple import { Highlight } from 'ark-ripple/highlight'; import styles from 'styles/highlight.module.css'; export component ExactMatch() {
{'Partial Match'}

{'Exact Match'}

} ``` ## API Reference **Component API Reference** **Highlight Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `query` | `string | string[]` | Yes | The query to highlight in the text | | `text` | `string` | Yes | The text to highlight | | `exactMatch` | `boolean` | No | Whether to match whole words only | | `ignoreCase` | `boolean` | No | Whether to ignore case while matching | | `matchAll` | `boolean` | No | Whether to match multiple instances of the query | ## Customization The Highlight component wraps matched text in `` tags. Pass a `className` (or `class` in Solid/Svelte/Vue) to style the highlighted portions. ```tsx ``` Style the `mark` tags using CSS to customize the appearance of highlighted text. ```css .highlight-mark { background-color: #ffe5e4; color: #c9453b; border-radius: 0.125rem; } ```