Skip to content

Commit 624e0f1

Browse files
committed
website: add example.
1 parent c3d2efa commit 624e0f1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

core/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,35 @@ export default function App() {
142142
}
143143
```
144144
145+
## Show LineNumbers
146+
147+
```jsx
148+
import rehypePrism from 'rehype-prism-plus';
149+
import React, { useState } from "react";
150+
import CodeEditor from '@uiw/react-textarea-code-editor';
151+
152+
export default function App() {
153+
const [code, setCode] = useState(
154+
`function add(a, b) {\n return a + b;\n}`
155+
);
156+
return (
157+
<CodeEditor
158+
value={code}
159+
language="js"
160+
placeholder="Please enter JS code."
161+
onChange={(evn) => setCode(evn.target.value)}
162+
rehypePlugins={[
163+
[rehypePrism, { ignoreMissing: true, showLineNumbers: true }]
164+
]}
165+
style={{
166+
backgroundColor: "#f5f5f5",
167+
fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace',
168+
}}
169+
/>
170+
);
171+
}
172+
```
173+
145174
## Support Nextjs
146175
147176
Use examples in nextjs. [#31](https://github.com/uiwjs/react-textarea-code-editor/issues/31#issuecomment-909363339)

0 commit comments

Comments
 (0)