All Projects → kawamataryo → vue-word-highlighter

kawamataryo / vue-word-highlighter

Licence: MIT license
The word highlighter library for Vue 2 and Vue 3.

Programming Languages

typescript
32286 projects
Vue
7211 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects
shell
77523 projects

Projects that are alternatives of or similar to vue-word-highlighter

vue2-timeago
🙌 A vue component used to format date with time ago statement. 💬
Stars: ✭ 76 (-32.14%)
Mutual labels:  vue-components, vue3
smart-tagz
🏷Smart input tags for Vue
Stars: ✭ 28 (-75%)
Mutual labels:  vue-components, vue3
hoc-element-table
📦 A Vue 3.x Table Component built on Webpack 5
Stars: ✭ 26 (-76.79%)
Mutual labels:  vue-components, vue3
fect
Minimalist UI components built on Vue-next
Stars: ✭ 352 (+214.29%)
Mutual labels:  vue-components, vue3
Vue3 News
🔥 Find the latest breaking Vue3、Vue CLI 3+ & Vite News. (2021)
Stars: ✭ 2,416 (+2057.14%)
Mutual labels:  vue-components, vue3
v-intl
Add i18n to your awesome Vue 3 app 🔉
Stars: ✭ 13 (-88.39%)
Mutual labels:  vue-components, vue3
vitepress-for-component
📖 针对组件开发的VitePress。
Stars: ✭ 142 (+26.79%)
Mutual labels:  vue-components, vue3
v-pip
🖼 Tiny vue wrapper for supporting native picture-in-picture mode.
Stars: ✭ 30 (-73.21%)
Mutual labels:  vue-components, vue3
Nutui
京东风格的移动端 Vue2、Vue3 组件库 (A Vue.js UI Toolkit for Mobile Web)
Stars: ✭ 3,870 (+3355.36%)
Mutual labels:  vue-components, vue3
codemirror-editor-vue3
CodeMirror component for Vue3
Stars: ✭ 22 (-80.36%)
Mutual labels:  vue-components, vue3
vue3-docs
vue中文社区,vue3 中文文档
Stars: ✭ 180 (+60.71%)
Mutual labels:  vue-components, vue3
vue-load-image
A Vue component for showing loader during image loading https://john015.github.io/vue-load-image/
Stars: ✭ 60 (-46.43%)
Mutual labels:  vue-components, vue3
vue-cirrus
Vue components for the Cirrus CSS framework.
Stars: ✭ 43 (-61.61%)
Mutual labels:  vue-components, vue3
vuestic-ui
Free and Open Source UI Library for Vue 3 🤘
Stars: ✭ 1,501 (+1240.18%)
Mutual labels:  vue-components, vue3
Different-UI
✨ A Vue.js 3 UI Library — a Toy
Stars: ✭ 62 (-44.64%)
Mutual labels:  vue-components, vue3
vui-vc-next
Vue 3 with Vite Playground - Mobile web UI components - (vue3+vite2).
Stars: ✭ 15 (-86.61%)
Mutual labels:  vue-components, vue3
vue-virtualised
Blazing fast scrolling and updating for any amount of list and hierarchical data.
Stars: ✭ 18 (-83.93%)
Mutual labels:  vue-components, vue3
chusho
A library of bare & accessible components and tools for Vue.js 3
Stars: ✭ 47 (-58.04%)
Mutual labels:  vue-components, vue3
app
专门为互联网人打造的题解神器,神器在手,工作不愁
Stars: ✭ 64 (-42.86%)
Mutual labels:  vue3
vue3-context-menu
A very simple context menu component for Vue3 一个简洁美观简单的Vue3右键菜单组件
Stars: ✭ 74 (-33.93%)
Mutual labels:  vue3

Vue Word highlighter

CI Downloads Version License GitHub stars

The word highlighter library for Vue 2 & Vue 3.

Demo

CodeSandbox

📦 Installation

Vue 3

yarn add vue-word-highlighter
# or
npm install vue-word-highlighter

Vue 2

powered by vue-demi.

yarn add vue-word-highlighter @vue/composition-api
# or
npm install vue-word-highlighter @vue/composition-api

If you get a Uncaught TypeError: e.defineComponent is not a function error, and it doesn't work, try this one from vue-demi

🚀 Usage

To use it, just provide it with search words to props and a body of text to default slots.

<template>
  <WordHighlighter query="vue">
    The word highlighter library for Vue 2.x Vue 3.x 💅
  </WordHighlighter>
  <!--  or
  <WordHighlighter 
    query="vue"
    textToHighlight="The word highlighter library for Vue 2.x Vue 3.x 💅"
  />
  -->
</template>

<script lang="ts">
import { defineComponent } from "vue";
import WordHighlighter from "vue-word-highlighter";

export default defineComponent({
  name: "App",
  components: {
    WordHighlighter,
  },
  setup() {
    return {};
  },
});
</script>

Output.

Details

Props

Property Type Required? Description
query String or RegExp Search words. Can be use string or regular expressions.
caseSensitive Boolean Whether string being searched is case sensitive. defaults to false.
diacriticsSensitive Boolean Whether string being searched is diacritics sensitive. defaults to false.
splitBySpace Boolean Whether split the string with spaces to make it a search string. If false, the string is being searched as a whole word. defaults to false. When the query is set to a RegExp, the value of splitBySpace will be set to false.
highlightTag String Type of tag to wrap around highlighted matches; defaults to mark.
highlightClass String or Object or Array Classes to be added to highlighted tag. Similar to class bindings in vue, it accepts Array syntax, Object syntax, or class as String.
highlightStyle String or Object or Array Styles to be applied to highlighted tag. Similar to style bindings in vue, it accepts Array syntax, Object syntax, or plain styling as String.
wrapperTag String Type of tag to wrap around whole text; defaults to span.
wrapperClass String or Object or Array Classes to be added to wrap around the whole tag. Similar to class bindings in vue, it accepts Array syntax, Object syntax, or class as String.
textToHighlight String Text to highlight matches in. If this is not specified, the default slot value will be used for the search.

Emits

Property Type Description
matches Array Returns matches words. This event fires when mounted and when the query and highlighted text are changed.

By using matches emit, you can know from the parent component whether it is highlighted by VueWordHighlighter or not.

Example
<template>
  <div>
    Matched word count: {{ matches.length }}
  </div>
  <WordHighlighter query="vue" @matches="(e) => { matches = e }">
    The word highlighter library for Vue 2.x Vue 3.x 💅
  </WordHighlighter>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
import WordHighlighter from "vue-word-highlighter";

export default defineComponent({
  name: "App",
  components: {
    WordHighlighter,
  },
  setup() {
    const matches = ref([]);
    return {
      matches
    };
  },
});
</script>

📄 License

vue-word-highlighter is available under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].