Skip to content

FTxTextHighlight

A component for highlighting text within a string, useful for search results.

Props

PropTypeDefaultDescription
textString''The text to display
queryString''The search query to highlight
caseSensitiveBooleanfalseCase-sensitive matching
highlightClassString'highlight'CSS class for highlighted text

Usage

vue
<template>
  <FTxTextHighlight
    :text="'Hello World'"
    :query="'world'"
  />
</template>

<script setup>
import { FTxTextHighlight } from '@ftx/ui';
</script>

Exported Utilities

  • indicesOf(text, query, caseSensitive) - Find all indices of query in text
  • mergeRange(ranges) - Merge overlapping ranges

Released under the MIT License.