Displays a code block with an optional header and output area.
The Code Block component is made up of six parts: Root, Output, Header, Content, Line Group, and Line. View source
A provider of the code editor context. Passes through the ref to the underlying codemirror editor.
A container for the code editor parts. Based on the div
element, implements Flex props.
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 div
element, and uses codemirror’s EditorView
to render the code.
In order to add syntax highlighting, you must pass in the appropriate extensions to the Root
component. Codemirror implements many of these, but you may also implement a Lezer grammar for custom languages.
An optional area to display elements related to the Code Block, like diagnostics. This component is based on the div
element.
An optional component that displays linting diagnostics. This component is based on the button element. Clicking it will navigate to the next diagnostic in the content.