{"id":51820519,"url":"https://github.com/SynTronic/ngx-highlight","last_synced_at":"2026-07-24T14:00:36.965Z","repository":{"id":371117875,"uuid":"1299019406","full_name":"SynTronic/ngx-highlight","owner":"SynTronic","description":"ngx-highlight","archived":false,"fork":false,"pushed_at":"2026-07-13T12:33:40.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-13T14:07:37.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SynTronic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-07-13T07:56:12.000Z","updated_at":"2026-07-13T12:25:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/SynTronic/ngx-highlight","commit_stats":null,"previous_names":["syntronic/ngx-highlight"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/SynTronic/ngx-highlight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SynTronic%2Fngx-highlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SynTronic%2Fngx-highlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SynTronic%2Fngx-highlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SynTronic%2Fngx-highlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SynTronic","download_url":"https://codeload.github.com/SynTronic/ngx-highlight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SynTronic%2Fngx-highlight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35844578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-24T02:00:07.870Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-22T05:00:25.535Z","updated_at":"2026-07-24T14:00:36.956Z","avatar_url":"https://github.com/SynTronic.png","language":"TypeScript","funding_links":[],"categories":["Third Party Components"],"sub_categories":["Directives"],"readme":"# @syntronic/ngx-highlight\n\nAngular directives for highlighting search matches in text, built on the native [CSS Custom Highlight API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API). No DOM mutation, no wrapping matched text in `\u003cmark\u003e` elements — ranges are painted directly by the browser.\n\n- Works across nested text nodes and multiple elements.\n- Supports a single group-wide search term, or several independent named searches within one group (e.g. per-column filters in a table).\n- Zoneless-friendly: built entirely on Angular signals (`input()`, `contentChildren()`, `afterRenderEffect()`).\n\n## Requirements\n\n- Angular `^22.0.0`\n- A browser with [`CSS.highlights`](https://developer.mozilla.org/en-US/docs/Web/API/CSS/highlights_static) support (Chromium, Safari; Firefox behind a flag as of writing). The directives no-op silently when unsupported.\n\n## Installation\n\n```bash\nnpm install @syntronic/ngx-highlight\n```\n\n## Usage\n\n### Basic: single search term\n\nWrap the searchable area with `ngxHighlightGroup`, pass it a unique highlight name and the current search term, then mark each searchable element with `ngxHighlightTarget`.\n\n```ts\nimport { Component, signal } from '@angular/core';\nimport { HighlightGroupDirective, HighlightTargetDirective } from '@syntronic/ngx-highlight';\n\n@Component({\n  selector: 'app-example',\n  imports: [HighlightGroupDirective, HighlightTargetDirective],\n  template: `\n    \u003cinput [value]=\"searchTerm()\" (input)=\"searchTerm.set($event.target.value)\" /\u003e\n\n    \u003cul [ngxHighlightGroup]=\"'device-list'\" [highlightSearchTerm]=\"searchTerm()\"\u003e\n      @for (device of devices; track device.id) {\n        \u003cli ngxHighlightTarget\u003e{{ device.name }}\u003c/li\u003e\n      }\n    \u003c/ul\u003e\n  `,\n})\nexport class ExampleComponent {\n  readonly searchTerm = signal('');\n  readonly devices = [\n    { id: 1, name: 'Water meter A1' },\n    { id: 2, name: 'Water meter B2' },\n  ];\n}\n```\n\nStyle the highlight with the [`::highlight()`](https://developer.mozilla.org/en-US/docs/Web/CSS/::highlight) pseudo-element, using the same name passed to `ngxHighlightGroup`:\n\n```css\n::highlight(device-list) {\n  background-color: yellow;\n  color: black;\n}\n```\n\n### Minimum match length\n\nAvoid highlighting on very short, noisy terms with `highlightMinLength` (default `1`):\n\n```html\n\u003cdiv [ngxHighlightGroup]=\"'device-list'\" [highlightSearchTerm]=\"searchTerm()\" [highlightMinLength]=\"3\"\u003e\n  \u003cspan ngxHighlightTarget\u003e{{ device.name }}\u003c/span\u003e\n\u003c/div\u003e\n```\n\nWith `highlightMinLength=\"3\"`, a search term of `\"he\"` produces no highlight; `\"hel\"` does.\n\n### Named searches: independent terms per column\n\nWhen a table (or any layout) needs a different search term per column, register each one with `ngxHighlightSearch` and pair it with a matching `ngxHighlightTarget` name. Unnamed targets keep matching the group-level `highlightSearchTerm` as before.\n\n```html\n\u003ctable [ngxHighlightGroup]=\"'device-table'\"\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003e\n        \u003cinput ngxHighlightSearch=\"name\" [highlightSearchTerm]=\"nameFilter()\" (input)=\"nameFilter.set($event.target.value)\" /\u003e\n      \u003c/th\u003e\n      \u003cth\u003e\n        \u003cinput ngxHighlightSearch=\"location\" [highlightSearchTerm]=\"locationFilter()\" (input)=\"locationFilter.set($event.target.value)\" /\u003e\n      \u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    @for (device of devices; track device.id) {\n      \u003ctr\u003e\n        \u003ctd [ngxHighlightTarget]=\"'name'\"\u003e{{ device.name }}\u003c/td\u003e\n        \u003ctd [ngxHighlightTarget]=\"'location'\"\u003e{{ device.location }}\u003c/td\u003e\n      \u003c/tr\u003e\n    }\n  \u003c/tbody\u003e\n\u003c/table\u003e\n```\n\nA named search unregisters itself automatically when its term becomes empty/`null`/`undefined`, or when the directive is destroyed.\n\n## API\n\n### `HighlightGroupDirective` (`[ngxHighlightGroup]`)\n\n| Input                 | Alias             | Type      | Default | Description                                                              |\n| ---------------------- | ----------------- | --------- | ------- | -------------------------------------------------------------------------- |\n| `highlightName`        | `ngxHighlightGroup` | `string` (required) | —       | The name registered in `CSS.highlights` — pair with `::highlight(name)`. |\n| `highlightSearchTerm`  | —                  | `string`  | `''`    | Group-wide search term applied to unnamed targets.                       |\n| `highlightMinLength`   | —                  | `number`  | `1`     | Minimum term length (after trim) before any highlighting occurs.         |\n\n### `HighlightTargetDirective` (`[ngxHighlightTarget]`)\n\n| Input                        | Alias               | Type      | Default | Description                                                                    |\n| ----------------------------- | -------------------- | --------- | ------- | ---------------------------------------------------------------------------------- |\n| `highlightSearchTargetName`  | `ngxHighlightTarget`  | `string`  | `''`    | When set, only matches the named search registered under the same name.          |\n\n### `HighlightSearchDirective` (`[ngxHighlightSearch]`)\n\n| Input                   | Alias              | Type                              | Default | Description                                        |\n| ------------------------ | -------------------- | ---------------------------------- | ------- | ----------------------------------------------------- |\n| `highlightSearchName`    | `ngxHighlightSearch`  | `string` (required)                | —       | Name shared with the matching `ngxHighlightTarget`. |\n| `highlightSearchTerm`    | —                    | `string \\| null \\| undefined` (required) | —       | The term for this named search.                    |\n\n## Development\n\nThis repository is an Angular CLI workspace containing a single library project (`projects/ngx-highlight`).\n\n```bash\nnpm install\nnpm run build   # ng build ngx-highlight -\u003e dist/ngx-highlight\nnpm run test    # ng test ngx-highlight (Vitest + real Chromium via vitest-browser-angular)\nnpm run lint    # ng lint ngx-highlight\n```\n\nTests run against real Chromium (not jsdom) because they assert against the live `CSS.highlights` registry, which jsdom does not implement.\n\n### Publishing\n\n```bash\nnpm run build\ncd dist/ngx-highlight\nnpm publish\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSynTronic%2Fngx-highlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSynTronic%2Fngx-highlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSynTronic%2Fngx-highlight/lists"}