• Stars
    star
    751
  • Rank 58,120 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React component for syntax highlighting

react-highlight

React component for syntax highlighting using highlight.js

Build Status

Latest version

0.11.1

Documentation

CodeSandbox Example

Edit new

Installation

  npm install react-highlight --save

Usage

Importing component

import Highlight from 'react-highlight'

Adding styles

Choose the theme for syntax highlighting and add corresponding styles of highlight.js

  <link rel="stylesheet" href="/path/to/styles/theme-name.css">

The styles will most likely be in node_modules/highlight.js/styles folder.

Props:

  • className: custom class name
  • innerHTML: enable to render markup with dangerouslySetInnerHTML
  • element: render code snippet inside specified element

Syntax highlighting of single code snippet

Code snippet that requires syntax highlighting should be passed as children to Highlight component in string format. Language name of code snippet should be specified as className.

<Highlight className='language-name-of-snippet'>
  {"code snippet to be highlighted"}
</Highlight>

Syntax highlighting of mutiple code snippets

Set innerHTML=true to highlight multiple code snippets at a time. This is especially usefull if html with multiple code snippets is generated from preprocesser tools like markdown.

Warning: If innerHTML is set to true, make sure the html generated with code snippets is from trusted source.

<Highlight innerHTML={true}>
  {"html with multiple code snippets"}
</Highlight>

More Repositories

1

react-slick

React carousel component
JavaScript
11,292
star
2

react-foundation-apps

Foundation Apps components built with React
JavaScript
292
star
3

json2mq

Generate media query string from JSON or javascript object
JavaScript
167
star
4

react-responsive-mixin

Mixin to develop responsive react components
JavaScript
95
star
5

awesome-mobx

Awesome list mobx resources
57
star
6

generator-react-foundation-apps

Start a project with react foundation apps quickly
CSS
37
star
7

can-use-dom

Test if you can use dom in the environment
JavaScript
20
star
8

timetracker

Timetracker application built with react-native
JavaScript
17
star
9

nextjs-demo

Next.js demos
JavaScript
11
star
10

react-isomorphic-example

JavaScript
10
star
11

foundation-material

Foundation for Apps and material design
CSS
9
star
12

string-convert

Set of string conversion functions
JavaScript
7
star
13

generator-react-slick

Starter kit for react-slick
CSS
7
star
14

graphql-asia-2019-workshop

JavaScript
6
star
15

reactfoo-delhi-react-workshop

JavaScript
5
star
16

react-native-layout-examples

JavaScript
4
star
17

rescript-react-workshop

CSS
4
star
18

react-test-examples

Basic examples for testing react components
JavaScript
4
star
19

react-layer-mixin

React mixin for building Layered components
JavaScript
4
star
20

react-todomvc

JavaScript
3
star
21

graphql-apollo-chat

JavaScript
3
star
22

react-ripple

Ripple effect of material design with react
JavaScript
3
star
23

react-india-2019-graphql-workshop

JavaScript
3
star
24

react-autosize

JavaScript
2
star
25

react-native-navigation-demos

JavaScript
2
star
26

react-hook-examples

JavaScript
2
star
27

react-ssr

React server side rendering with express and webpack
JavaScript
2
star
28

react-native-analog-clock

Simple analog clock create with react-native
JavaScript
2
star
29

apollo-link-cache

JavaScript
2
star
30

graphql-asia-2020-workshop

JavaScript
2
star
31

gulp-jsxformat

prettify jsx with gulp
JavaScript
2
star
32

rescript-binding-examples

1
star
33

reason-react-swapi

Reason
1
star
34

relay-todo

JavaScript
1
star
35

dataviz-workshop-demos

JavaScript
1
star
36

graphql-relay-todo

JavaScript
1
star
37

react-animation-demos

JavaScript
1
star
38

reddit-clone

JavaScript
1
star
39

react-materialize

react port of materialize
1
star
40

react-form-examples

Example forms built with react
JavaScript
1
star
41

webpack-demo

JavaScript
1
star
42

react-beginners-workshop

JavaScript
1
star
43

graphql-urql-chat

JavaScript
1
star
44

apollo-mutation-issue

JavaScript
1
star
45

devday-offline-demo

JavaScript
1
star
46

gulp-sassbeautify

Beautify sass and scss with gulp
JavaScript
1
star
47

reason-react-todomvc

Reason
1
star
48

graphql-apollo-todo

Simple todo app built with GraphQL, Apollo, React
JavaScript
1
star
49

apollo-todo

JavaScript
1
star
50

todo-app

Simple todo app written in react
CSS
1
star
51

hasura-relay-todo

JavaScript
1
star
52

reactfoo-mumbai-graphql-workshop

JavaScript
1
star
53

ReactNativeCalculator

Simple Calculator built with react native
JavaScript
1
star
54

mq2json

Parse media query string to json
JavaScript
1
star
55

jan2017-training

JavaScript
1
star