With the Highlight component, you can spotlight words.
import { Highlight } from "@chakra-ui/react"
export const HighlightBasic = () => {
  return (
    <Highlight
      query="spotlight"
      styles={{ px: "0.5", bg: "orange.subtle", color: "orange.fg" }}
    >
      With the Highlight component, you can spotlight words.
    </Highlight>
  )
}
import { Highlight } from "@chakra-ui/react"<Highlight query="Hello">Hello World</Highlight>Pass an array of strings to the query prop to highlight multiple substrings.
With the Highlight component, you can spotlight, emphasize and accentuate words.
import { Heading, Highlight } from "@chakra-ui/react"
export const HighlightMultiple = () => {
  return (
    <Heading lineHeight="tall">
      <Highlight
        query={["spotlight", "emphasize", "Accentuate"]}
        styles={{ px: "0.5", bg: "teal.muted" }}
      >
        With the Highlight component, you can spotlight, emphasize and
        accentuate words.
      </Highlight>
    </Heading>
  )
}
Use the styles prop to customize the style of the highlighted text.
With the Highlight component, you can spotlight words.
import { Highlight } from "@chakra-ui/react"
export const HighlightWithCustomStyle = () => {
  return (
    <Highlight query="component" styles={{ fontWeight: "semibold" }}>
      With the Highlight component, you can spotlight words.
    </Highlight>
  )
}
Use the highlight component to highlight search query results.
Search result for: spot
Spotlight bulb
Spot cleaner
Spot ceiling
import { Highlight, Stack, Text } from "@chakra-ui/react"
const query = "spot"
const results = ["Spotlight bulb", "Spot cleaner", "Spot ceiling"]
export const HighlightSearchQuery = () => {
  return (
    <Stack gap="6">
      <Text>Search result for: spot</Text>
      <Stack gap="1">
        {results.map((item) => (
          <p key={item}>
            <Highlight
              ignoreCase
              query={query}
              styles={{ fontWeight: "semibold" }}
            >
              {item}
            </Highlight>
          </p>
        ))}
      </Stack>
    </Stack>
  )
}
| Prop | Default | Type | 
|---|---|---|
| query * | string | string[]The query to highlight in the text | |
| text * | stringThe text to highlight | |
| ignoreCase  | booleanWhether to ignore case while matching | |
| matchAll  | booleanWhether to match multiple instances of the query | |
| styles  | SystemStyleObject |