Skip to content

steffanny-dawson/react-highlight

 
 

Repository files navigation

Unlimited React components logologo

React Highlight

npm latest package npm latest package dependencies Status Coverage Status Build Status Known Vulnerabilities Total alerts Language grade: JavaScript

If you have any issue or suggestion, or wanna improve the repo adding other languages highlights, let me know it on the github section: "issues", or make a pull request.

Description

Highlight your JSX code with a react Highlight component.

Sample result:

Sample result image

Installation

react-highlight is available as an npm package.

// with npm
npm i @unlimited-react-components/react-highlight

Usage

Here is a quick example to get you started, it's all you need:

Edit Button

import "./styles.css";
import { Highligther } from "@unlimited-react-components/react-highlight";

const App = (props) => {
  return (
      <Highligther 
        code={makeCode} 
      />
  );
};
export default App;
const makeCode = `
    // this is a sample code
    const themes = {
      light: { ... },
      dark:  { ... }
    };
    const ThemeContext = React.createContext(themes.light);
    function App() {
      return (
        <ThemeContext.Provider value={themes.dark}>
          <Toolbar />
        </ThemeContext.Provider>
      );
    }
    function Toolbar(props) { ... }
    
    const ThemedButton =() => { ... }
`;

Props

Name Description Default
code The JSX code to be highlighted. ""
language The programming language JSX: the only language supported for now
style The in-line CSS object. Only affects the container { }

License

This project is licensed under the terms of the MIT license.

About

A react component for highlighting JSX code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 80.3%
  • JavaScript 12.8%
  • SCSS 6.9%