Skip to content

Commit 971e08a

Browse files
committed
chore(package): Update README.md
1 parent f230a10 commit 971e08a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

package/README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
> [!WARNING]
2-
> This package is still a work in progress, it is not yet recommended for production use.
2+
> This package is still a work in progress, it is not yet recommended for production use. Contributions are welcome! My goal is to eventually build this out as a drop in replacement for `react-syntax-highlighter`
33
44

55
# 🎨 [react-shiki](https://react-shiki.vercel.app/)
@@ -10,17 +10,30 @@ Syntax highlighting component for react using [Shiki](https://shiki.matsu.io/)
1010
See the [demo](https://react-shiki.vercel.app/) page with multiple theme examples and usage instructions!
1111

1212
## Installation
13+
1314
```bash
14-
npm install react-shiki
15+
(pnpm|bun|yarn) add react-shiki
1516
```
1617
or
1718

1819
```bash
19-
(pnpm|bun|yarn) add react-shiki
20+
npm install react-shiki
2021
```
2122

2223
## Usage
2324

25+
You can use the `ShikiHighlighter` component, or the `useShikiHighlighter` hook to highlight code.
26+
27+
28+
`useShikiHighlighter` is a custom hook that takes in the code to be highlighted, the language, and the theme, and returns the highlighted code as a string:
29+
```tsx
30+
const highlightedCode = useShikiHighlighter(code, language, theme);
31+
```
32+
33+
The `ShikiHighlighter` component is imported in your project, with the code to be highlighted passed as it's children.
34+
35+
Shiki automatically handles dynamically importing only the languages and themes used on the page.
36+
2437
```tsx
2538
function CodeBlock() {
2639
return (
@@ -30,9 +43,7 @@ function CodeBlock() {
3043
);
3144
}
3245
```
33-
The ShikiHighlighter is imported in your project and used as a component, with code to be highlighted passed as children.
3446

35-
Shiki handles dynamically imports only the languages and themes used on the page.
3647

3748
The component accepts several props in addition to language and theme:
3849

@@ -41,7 +52,7 @@ The component accepts several props in addition to language and theme:
4152
- `as: string` - The component to be rendered. Defaults to 'pre'.
4253
- `className: string` - Class name to be passed to the component.
4354

44-
It can also be used with `react-markdown`
55+
It can also be used with `react-markdown`:
4556
```tsx
4657
import type { ReactNode } from 'react';
4758
import type { BundledLanguage } from 'shiki';
@@ -80,7 +91,7 @@ export const CodeHighlight = ({
8091
};
8192
```
8293

83-
Pass CodeHighlight to `react-markdown` as a code component
94+
Pass CodeHighlight to `react-markdown` as a code component:
8495
```tsx
8596
import ReactMarkdown from 'react-markdown';
8697
import { CodeHighlight } from './CodeHighlight';

0 commit comments

Comments
 (0)