Description
react-highlight is a React component for syntax highlighting, built on the highlight.js library. You pass a code snippet as the children of the Highlight component as a string, and set its language through a className, so the code is coloured according to that language. The README shows installation, the import of the component, and how to add a highlight.js theme. The theme styles are CSS files in the highlight.js package, so you import the one you want. The component takes a few props: className for a custom class name, innerHTML to render markup that contains code, and element to choose which element the snippet is rendered inside. When innerHTML is set to true, the component highlights every code snippet in a block of HTML at once, which is useful when the HTML comes from a tool such as a markdown renderer. The README warns that innerHTML should only be used with HTML from a trusted source, because it renders the markup directly. The latest version listed is 0.11.1. The project has a CodeSandbox example and a public source repository on GitHub.…
Highlights
- Syntax highlighting using highlight.js
- Snippet highlighting by language class name
- innerHTML mode for markdown-generated HTML
- Choice of highlight.js theme
- CodeSandbox example
Ratings & Reviews
No ratings yet
Be the first to rate react-highlight.
People also visit

ngx-highlightjs
Instant code highlighting, auto-detect language, super easy to use!
react-highlight FAQ
What is react-highlight?
A React component that colours code snippets using the highlight.js library.
Is it free?
Yes. The source is public on GitHub and listed as open source.
How do I pick a language?
Pass the code as the children of Highlight and set the language name as its className.
Is innerHTML safe?
The README warns that innerHTML should only be used with HTML from a trusted source, since the markup is rendered directly.
What are the best react-highlight alternatives?
Popular alternatives to react-highlight include react-markdown, react-highlighter and react-markdown. See all react-highlight alternatives


















