Code Block
Storybook
View this component in the Storybook sandbox
GitHub
Browse the files and source code related to this component
The Code Block component can be used to display snytax highlighted code snippets.
Anatomy
Usage Guidelines
The CodeBlock component should only be used for code. Code examples should be concise and easy to understand, but practical and useful.
When to consider a different component
For preformatted content other than code, consider using the pre
element alone.
Implementation
This component is not available in WordPress, but is available in the UA Framework for static sites. It uses Prism JS
to provide syntax highlighting, but the UA Framework does not include the Prism JS library by default. You will need to include the Prism JS library in your project to use this component with syntax highlighting.
React Component Props
- lang
string (required)
- The code language identifier (see list here)
- children
ReactNode (required)
- The code snippet
- caption
string
- The code caption, this defaults to the value of the
lang
prop - className
string
- Additional classes to add to the ua_component_wrapper