Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-code-highlighter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-code-highlighter

test

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
586
increased by6.93%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-code-highlighter

GitHub CI Coverage Status npm npm

Code/Syntax highlighter for React Native. Inspired by react-native-syntax-highlighter, using react-syntax-highlighter

Installation

NPM
npm install react-native-code-highlighter react-syntax-highlighter
Yarn
yarn add react-native-code-highlighter react-syntax-highlighter

Additional for typescript

NPM
npm install --save-dev @types/react-syntax-highlighter
Yarn
yarn add -D @types/react-syntax-highlighter

Usage

Props

PropDescriptionTypeOptional
hljsStyleHighlight.js style imported from react-syntax-highlighter/dist/esm/styles/hljs{ [key: string]: React.CSSProperties }false
textStyleStyle for the text text components. Note: color property will be overriddenStyleProp<TextStyle>true
scrollViewPropsProps for the underlying scroll view. horizontal is ignoredScrollViewPropstrue
containerStyleDeprecated. containerStyle for the underlying ScrollView. Use scrollViewProps.contentContainerStyle insteadStyleProp<ViewStyle>true
react-syntax-highlighter PropsProps supported by react-syntax-highlighter. i.e. language

Example

import React from "react";
import { StyleSheet } from "react-native";
import CodeHighlighter from "react-native-code-highlighter";
import { atomOneDarkReasonable } from "react-syntax-highlighter/dist/esm/styles/hljs";

const CODE_STR = `var hello = "world"`;

export default function HighlightComponent() {
	return (
		<CodeHighlighter
			hljsStyle={atomOneDarkReasonable}
			containerStyle={styles.codeContainer}
			textStyle={styles.text}
			language="typescript"
		>
			{CODE_STR}
		</CodeHighlighter>
	);
}

const styles = StyleSheet.create({
	codeContainer: {
		padding: 16,
		minWidth: "100%",
	},
	text: {
		fontSize: 16,
	},
});

CodeSandbox: https://codesandbox.io/s/react-native-code-highligher-knfsyx?file=/src/App.js

Screenshots

Image

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Built using

Buy Me A Coffee

Keywords

FAQs

Package last updated on 26 Oct 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc