npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ng-text-highlight

v2.0.4

Published

A lightweight standalone Angular 19 component/module for highlighting text.

Readme

ng-text-highlight

🔍 A lightweight Angular standalone component to highlight search keywords within a block of text.

🌐 Homepage: https://ng-text-highlight.web.app/

npm version Downloads License: MIT

🚀 Why Choose ng-text-highlight?

  • 🎯 Perfect for Search Results: Highlight search terms in search results, documentation, and content
  • ⚡ Lightweight & Fast: Minimal bundle size with optimal performance
  • 🎨 Fully Customizable: Custom CSS classes, inline styles, and prebuilt themes
  • 🔧 Easy Integration: Works with Angular 14+ as standalone component or module
  • 📱 Mobile Friendly: Responsive design that works on all devices
  • 🔍 Smart Search: Case-sensitive/insensitive search with multiple keyword support
  • ♿ Accessible: Built with accessibility best practices

🎯 Use Cases

  • Search Results: Highlight search terms in search result pages
  • Documentation: Highlight keywords in help articles and documentation
  • Content Filtering: Visual feedback for filtered content
  • Code Editors: Syntax highlighting and keyword emphasis
  • E-commerce: Highlight product features and specifications
  • Educational Apps: Emphasize important terms in learning materials

📦 Installation

npm install ng-text-highlight

🚀 Usage

You can use TextHighlightComponent in two ways:


✅ Option 1: Import as a Standalone Component

If you're using Angular 14+ and prefer standalone components:

import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "./app.component";
import { FormsModule } from "@angular/forms";
import { TextHighlightComponent } from "ng-text-highlight";

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, FormsModule, TextHighlightComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Template Example:

<div>
  <h4>Highlighted Text:</h4>
  <ng-text-highlight
    [fullText]="sampleText"
    [keywords]="sampleSearchText.split(' ')"
  >
  </ng-text-highlight>
</div>

✅ Option 2: Import via Module (TextHighlightModule)

If you prefer using Angular modules:

import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "./app.component";
import { FormsModule } from "@angular/forms";
import { TextHighlightModule } from "ng-text-highlight";

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, FormsModule, TextHighlightModule],
  bootstrap: [AppComponent],
})
export class AppModule {}

Template Example:

<div>
  <h4>Highlighted Text:</h4>
  <ng-text-highlight
    [fullText]="sampleText"
    [keywords]="['Angular', 'text', 'highlight']"
  >
  </ng-text-highlight>
</div>

🧠 Inputs

| Input | Type | Description | | ---------------- | --------------------------- | ----------------------------------------------------------------------------- | | fullText | string | The main text where keywords will be highlighted | | keywords | string[] | List of keywords to highlight | | caseSensitive | boolean | Whether the search should be case-sensitive (default: false) | | highlightClass | string | Custom CSS class for highlighted text (default: 'highlight') | | highlightStyle | { [key: string]: string } | Inline styles for highlighted text (e.g., { 'background-color': 'yellow' }) |


🎨 Prebuilt Styles

The following prebuilt styles are available for quick use:

| Class Name | Description | | ------------------ | --------------------------------- | | highlight | Default yellow highlight | | highlight-green | Light green highlight | | highlight-blue | Light blue highlight | | highlight-red | Red highlight with white text | | highlight-purple | Purple highlight with italic text | | highlight-orange | Orange highlight |

Example Usage:

<ng-text-highlight
  [fullText]="sampleText"
  [keywords]="['Angular', 'highlight']"
  [highlightClass]="'highlight-green'"
></ng-text-highlight>

🎨 Custom Inline Styles

You can also pass custom inline styles using the highlightStyle input:

Example Usage:

<ng-text-highlight
  [fullText]="sampleText"
  [keywords]="['Angular', 'highlight']"
  [highlightStyle]="{ 'background-color': 'lightblue', 'color': 'black', 'font-weight': 'bold' }"
></ng-text-highlight>

📄 License

This package is licensed under the MIT License. See the LICENSE file for details.


📸 Example Output

Below is an example of how the ng-text-highlight component highlights text:

Highlighted Text Example


⭐ Support

Give this repo a ⭐ if you find it useful!