Gathering detailed insights and metrics for vue-highlight-words
Gathering detailed insights and metrics for vue-highlight-words
Gathering detailed insights and metrics for vue-highlight-words
Gathering detailed insights and metrics for vue-highlight-words
vue-words-highlight
Highlight words for Vue.js
solid-highlight-words
Solid component for syntax highlighting, based on react-highlight and highlightjs' vue plugin
v-highlight-3
Highlight words with this simple and dependency-less Vue 3 directive
vue-mark-words
A Vue component for mark and highlighting words within text with flexible word boundary matching and customizable styling.
🖍 Vue component to highlight words within a larger body of text.
npm install vue-highlight-words
Typescript
Module System
Node Version
NPM Version
JavaScript (52.26%)
TypeScript (47.74%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
76 Stars
49 Commits
5 Forks
3 Watchers
9 Branches
2 Contributors
Updated on May 20, 2025
Latest Version
3.0.1
Package Id
vue-highlight-words@3.0.1
Unpacked Size
35.42 kB
Size
9.10 kB
File Count
9
NPM Version
6.14.17
Node Version
14.19.3
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
28
:information_source: This is the branch for vue-highlight-words 2 (For Vue 3). If you are looking for Vue 2.0 support, please check out 1.0
branch
A simple port from
react-highlight-words
Vue component to highlight words within a larger body of text.
It uses render
to handle the highlighted text instead of using v-html
or el.innerHtml
.
npm i --save vue-highlight-words
To use it, just provide it with an array of search terms and a body of text to highlight.
1<template> 2 <div id="app"> 3 // attrs on component are applied to the wrapper `<span>` 4 <Highlighter class="my-highlight" :style="{ color: 'red' }" 5 highlightClassName="highlight" 6 :searchWords="keywords" 7 :autoEscape="true" 8 :textToHighlight="text"/> 9 </div> 10</template> 11 12<script> 13import Highlighter from 'vue-highlight-words' 14 15export default { 16 name: 'app', 17 components: { 18 Highlighter 19 }, 20 data() { 21 return { 22 text: 'The dog is chasing the cat. Or perhaps they\'re just playing?', 23 words: 'and or the' 24 } 25 }, 26 computed: { 27 keywords() { 28 return this.words.split(' ') 29 } 30 } 31} 32</script>
And the Highlighter
will mark all occurrences of search terms within the text:
Property | Type | Required? | Description |
---|---|---|---|
activeClassName | String | The class name to be applied to an active match. Use along with activeIndex | |
activeIndex | Number | Specify the match index that should be actively highlighted. Use along with activeClassName | |
activeStyle | Object | The inline style to be applied to an active match. Use along with activeIndex | |
autoEscape | Boolean | Escape characters in searchWords which are meaningful in regular expressions | |
caseSensitive | Boolean | Search should be case sensitive; defaults to false | |
findChunks | Function | Use a custom function to search for matching chunks. This makes it possible to use arbitrary logic when looking for matches. See the default findChunks function in highlight-words-core for signature. Have a look at the custom findChunks example on how to use it. | |
highlightClassName | String | CSS class name applied to highlighted text | |
highlightStyle | Object | Inline styles applied to highlighted text | |
sanitize | Function | Process each search word and text to highlight before comparing (eg remove accents); signature (text: string): string | |
searchWords | Array | ✓ | Array of search words. The search terms are treated as RegExps unless autoEscape is set. |
textToHighlight | String | ✓ | Text to highlight matches in |
Use a default slot with v-slot
props
1type SlotProps = HighlighterItem[] 2 3type HighlighterItem = { 4 text: string // chunk of text to render 5 attrs: HighlightAttrs 6 chunk: Chunk 7} 8 9type HighlightAttrs = { 10 class: string // class for highlight tag: highlightClassNames 11 key: number // index of the chunk 12 style: Partial<CSSStyleDeclaration> // highlightStyles 13 highlightIndex: number // index of highlight tag 14} 15 16type Chunk = { 17 start: number 18 end: number 19 highlight: boolean 20}
1 <template> 2 <div id="app"> 3 // attrs on component are applied to the wrapper `<span>` 4 <Highlighter class="my-highlight" :style="{ color: 'red' }" 5 highlightClassName="highlight" 6 :searchWords="keywords" 7 :autoEscape="true" 8- :textToHighlight="text"/> 9+ :textToHighlight="text" 10+ v-slot="items"> 11+ <div> 12+ <span v-for="{chunk, text, attrs} in items" :key="attrs.key" 13+ :class="{chunk.highlight: 'highlight' : ''}" 14+ >{{text}}</span> 15+ </div> 16+ </Highlighter> 17 </div> 18 </template> 19 20 <script> 21 import Highlighter from 'vue-highlight-words' 22 23 export default { 24 name: 'app', 25 components: { 26 Highlighter 27 }, 28 data() { 29 return { 30 text: 'The dog is chasing the cat. Or perhaps they\'re just playing?', 31 words: 'and or the', 32 } 33 }, 34 computed: { 35 keywords() { 36 return this.words.split(' ') 37 } 38 } 39 } 40 </script>
pnpm install
pnpm dev
pnpm build
pnpm lint
MIT License - fork, modify and use however you want.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More