Socket
Socket
Sign inDemoInstall

rc-highlight

Package Overview
Dependencies
2
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rc-highlight

React component for highlighting js, ts, jsx and tsx code


Version published
Weekly downloads
84
decreased by-36.84%
Maintainers
1
Install size
159 kB
Created
Weekly downloads
 

Readme

Source

✨🖍️ React Highlight ✨🖍️

React component for highlighting js and jsx code with copy to clipboard functionallity.

license npm latest package install size Build Status Known Vulnerabilities Language grade: JavaScript Total alerts

Sample result:

Sample result image

Installation

react-highlight is available as an npm package.

// with npm
npm i rc-highlight

// or yran
yarn add rc-highlight

Usage

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

Edit Button

import "./styles.css";
import { Highligther } from "rc-highlight";

const App = (props) => {
  return <Highlighter>{makeCode}</Highlighter>;
};
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

NameDescriptionDefault
codeThe JSX code to be highlighted.""
styleThe in-line CSS object. Only affects the container{ }
childrenThe JSX code to be highlighted in string format.""
onCopyToClipboardA Funtion that is triggered when copy to clipboard button is clicked. Returns the copied code as a string as first parameter.undefined
copyToClipBoardIf true, a button to copy the code to clipboard will be visibletrue

License

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

Keywords

FAQs

Last updated on 26 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc