Code Block Component

A feature-rich code block component with syntax highlighting, line numbers, copy functionality, and command-line interface support.

;
Live Preview
Experiment with the CodeBlock component using the controls below
Props
Detailed information about the component's props
PropTypeRequiredDefaultDescription
codestring
Yes
-The code content to be displayed in the block.
languagestring
No
"typescript"Programming language for syntax highlighting. Supported languages include typescript, javascript, jsx, tsx, css, python, java, json, bash, markdown.
showLineNumbersboolean
No
trueWhether to show line numbers in the code block.
showLineNumbersTogglerboolean
No
falseWhether to show line numbers Toggler in the code block header.
showCopyButtonboolean
No
trueWhether to show the copy button.
showLanguageLabelboolean
No
trueWhether to show the language label in the header.
overwriteLanguageLabelstring
No
""To overwrite the language label in the header.
theme"light" | "dark"
No
"dark"Color theme for the code block.
classNamestring
No
-Additional CSS classes to apply to the container.
isCommandLineboolean
No
falseWhether to render the code block as a command-line interface.
commandLineCommandLineConfig
No
{ user: "user", host: "localhost", path: "~", basePrompt: "", continuationPrompt: "→ " }Configuration for command-line interface display, including user, host, path, and prompts.
Explore More Components
Discover other components available in OpenReactHub
Contribute
Learn how you can contribute to OpenReactHub