Code Block

Displays a code block with an optional header and output area.

helloWorld();

Import the component and piece the parts together.

The Code Block component is made up of six parts: Root, Output, Header, Content, Line Group, and Line. View source

Groups the Code Block parts. This component is based on the div element and supports common margin props m, mx, my, ml, mr, mt, mb.

An optional area to display the output of the Code Block, like a rendered React component or a result of a bash command. This component is based on the output element.

An optional area to display elements related to the Code Block, like its title, tabs, or current language. This component is based on the div element.

Code contents of the Code Block. This component is based on the pre element.

There is no automatic syntax highlighting – pick any tech that fits your project.

Provides layout and gutters to the Lines. The gutters may show automatic line numbers or indicate a CLI interface. This component is based on the table element.

PropTypeDefault
gutter"numbers" | "cli" | "none""numbers"

An optional component that renders a line of code. Must be used within a Line Group. This component is based on the tr element.

PropTypeDefault
color"yellow" | "green" | "red"

Use the Output part to display the result of running the Code Block code.

I love Bash

Use the Header part to display related information, like the Code Block title and language.

Install the WorkOS SDKBash

The Code Block design can accommodate Tabs in the header.

Bash

Use gutter="cli" to display gutters that indicate a command line interface. The second and subsequent lines will indicate a multi-line input.

Use gutter="numbers" to display automatic line numbers in the gutters.

Use the color prop to highlight a code line.

Use the blue highlight when you need a more subtle call-out in the code block.

Green and red highlight colors automatically display plus and minus symbols in the gutter, indicating added and removed lines.