# Highlight

> Marks search terms in a text, for search hits in mail, chat and lists.

Component · Foundations · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/Highlight/)

Marks search terms in a text, for search hits in mail, chat and lists. `query` marks each word of the input (case-insensitive), `exact` the whole input as one phrase, and `terms` a list you pass. `highlightParts(text, terms)` returns the parts for your own markup.

## Example

```tsx
import * as React from "react";
import { Highlight, TextField } from "@twentyfirstmedia/pro";

const LINES = [
  "Invoice RE-2026-00041 for the November retainer is overdue.",
  "The offsite moves to the lake house; invoices go to finance.",
  "Draft of the hiring plan with the new design roles.",
];

export default function Preview() {
  const [query, setQuery] = React.useState("invoice plan");
  return (
    <div className="tf-panel" style={{ gap: 12 }}>
      <TextField label="Search" value={query} onChange={(e) => setQuery(e.target.value)} />
      {LINES.map((line) => (
        <p key={line} style={{ margin: 0 }}>
          <Highlight text={line} query={query} />
        </p>
      ))}
    </div>
  );
}
```

## Props

### Highlight

| Prop | Type | Notes |
| --- | --- | --- |
| `text` | `string` | Required |
| `query?` | `string` | Search input: each word is marked (or the whole input with `exact`). |
| `terms?` | `string[]` | The terms to mark, instead of `query`. |
| `exact?` | `boolean` | Marks `query` as one phrase instead of word by word. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### TextField

| Prop | Type | Notes |
| --- | --- | --- |
| `type?` | `string` | Input type (`"text"` by default): `"email"`, `"number"`, `"tel"`, `"url"`, `"password"` … |
| `icon?` | `IconName` |  |
| `suffix?` | `ReactNode` |  |
| `value?` | `string` |  |
| `defaultValue?` | `string` |  |
| `placeholder?` | `string` |  |
| `disabled?` | `boolean` |  |
| `readOnly?` | `boolean` |  |
| `autoComplete?` | `string` |  |
| `autoFocus?` | `boolean` |  |
| `min?` | `number \| string` | Smallest value for `type="number"`, `"date"` and the like (native `min`). |
| `max?` | `number \| string` | Largest value (native `max`). |
| `step?` | `number \| string` | Step between valid values (native `step`), e.g. `1` for whole numbers or `"any"`. |
| `minLength?` | `number` | Fewest characters (native `minlength`). |
| `maxLength?` | `number` | Most characters (native `maxlength`). |
| `pattern?` | `string` | Pattern the value must match (native `pattern`). |
| `inputMode?` | `"none" \| "text" \| "tel" \| "url" \| "email" \| "numeric" \| "decimal" \| "search"` | Virtual keyboard on touch devices (native `inputmode`), e.g. `"numeric"` or `"decimal"`. |
| `onChange?` | `(e: ChangeEvent<HTMLInputElement>) => void` |  |
| `onBlur?` | `(e: ChangeEvent<HTMLInputElement>) => void` |  |
| `onKeyDown?` | `(e: KeyboardEvent<HTMLInputElement>) => void` |  |
| `action?` | `ReactNode` | An interactive control at the end of the field (an `IconButton`: clear, copy, locate …). Unlike `suffix` it can be clicked, and it stays when the field shows an error or success mark. |
| `reveal?` | `boolean` | For `type="password"`: a button that shows and hides the password (default true). |
| `label?` | `string` |  |
| `hint?` | `string` |  |
| `error?` | `string` |  |
