A lightweight and customizable syntax highlighting library built on top of Mantine's code highlight component. It provides pre-configured components and utilities for seamless integration into React applications.
-
Mantine Integration: Built on top of
@mantine/code-highlight
for robust and flexible syntax highlighting. - Customizable: Easily customize syntax highlighting styles and behavior to fit your application's needs.
- TypeScript Support: Fully typed for a better developer experience.
- Lightweight: Minimal dependencies for fast and efficient performance.
Install the library using pnpm
, npm
, or yarn
:
# Using pnpm
pnpm add @toolsify/highlight
# Using npm
npm install @toolsify/highlight
# Using yarn
yarn add @toolsify/highlight
Make sure the following peer dependencies are installed in your project:
react
react-dom
@toolsify/core
You can install them using:
pnpm add react react-dom @toolsify/core
Use the @toolsify/highlight
library to create a basic syntax highlighting component in your React application.
import React from "react";
import { CodeHighlight } from "@toolsify/highlight";
const App = () => {
return (
<CodeHighlight language="javascript">
{`const greet = () => console.log("Hello, World!");`}
</CodeHighlight>
);
};
export default App;
You can customize the syntax highlighting styles and behavior by passing props.
import React from "react";
import { CodeHighlight } from "@toolsify/highlight";
const App = () => {
return (
<CodeHighlight
language="typescript"
withLineNumbers
highlightLines={[2]}
>
{`const greet = () => {
console.log("Hello, World!");
};`}
</CodeHighlight>
);
};
export default App;
The library re-exports types from @mantine/code-highlight
for better type safety.
import React from "react";
import { CodeHighlightProps } from "@toolsify/highlight";
const CustomCodeHighlight = (props: CodeHighlightProps) => {
return <CodeHighlight {...props} />;
};
export default CustomCodeHighlight;
This project is licensed under the MIT License.