hrdtbs / react-code

Home Page:https://www.npmjs.com/package/@hrdtbs/react-code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yarn add @hrdtbs/react-code

Prismjs

Examples

useCode(language: string): React.RefObject

Highlight the element given ref in the specified language using Prismjs.

Code: FunctionComponent<Partial<language: string>>

Code block element. children must be string.

import { Code } from "@hrdtbs/react-code"
export default () => (
    <Code>{`

        function func(){
            console.log("hello")
        }

    `}</Code>
)

The above is output like the following code.

function func(){
    console.log("hello")
}

Unwanted spaces are removed automatically.

CodeInline: FunctionComponent<Partial<language: string>>

Code inline element. children must be string.

CodeCollapse: FunctionComponent<Partial<{language: string;summary: string;open: boolean;}>>

Openable Code block element. children must be string.

About

https://www.npmjs.com/package/@hrdtbs/react-code


Languages

Language:JavaScript 68.0%Language:TypeScript 32.0%