
Description
ngx-highlightjs is an Angular module that adds syntax highlighting to code on a page, using highlight.js. You add a directive to an element, and the library highlights the code, with an option to detect the language automatically. Installation is through npm, and the README shows how to provide highlight.js options in app.config.ts with provideHighlightOptions. Options include a loader for the full library, separate loaders for the core library and the languages you need, a loader for line numbers, a configuration object, line number settings and a path to the theme file. You can load the script lazily, and you can import a highlight.js theme in several ways, including a CDN link. A HighlightLoader service has a setTheme method for switching themes when the app's theme changes. The README notes that the full library includes all languages, and that the core loader lets you load only the languages you need. A live demo is on StackBlitz.…
Highlights
- Angular directives for code highlighting
- Automatic language detection
- Line numbers addon
- Lazy loading of highlight.js
- Theme switching with setTheme
Ratings & Reviews
No ratings yet
Be the first to rate ngx-highlightjs.
People also visit

domternal
Lightweight, extensible rich text editor toolkit with native Angular components
ngx-highlightjs FAQ
What is ngx-highlightjs?
An Angular module for syntax highlighting, built on highlight.js.
How do I install it?
Install it with npm, then provide the highlight.js options in app.config.ts using provideHighlightOptions.
Can I load fewer languages?
Yes. Use the core library loader and register only the languages you need. The README notes the full library includes every language.
Can I switch themes?
Yes. Set the theme path in the global configuration, then call setTheme from the HighlightLoader service when the app theme changes.
What are the best ngx-highlightjs alternatives?
Popular alternatives to ngx-highlightjs include ngx-markdown, react-highlight and ngx-quill. See all ngx-highlightjs alternatives















