Default
A container for content representing programming languages.
Flat
Codeblock with flat container styling for minimal visual emphasis.
Theme
Light and dark theme variations for different UI contexts.
Copy
Codeblock with copy button action for easy code sharing and reuse.
Code
\n"} <nve-codeblock language="typescript" id="code-property"></nve-codeblock>
<script type="module">
import "@nvidia-elements/code/codeblock/define.js";
import "@nvidia-elements/code/codeblock/languages/typescript.js";
const codeblock = document.querySelector("nve-codeblock#code-property");
codeblock.code = 'console.log("hello, world!")';
</script>
Edit Example
Text code to be process into a codeblock.
Line Numbers
Adds styling to show the line numbers of the codeblock.
Highlight
Adds styling to highlight the provided code lines.For many lines: use Comma seperated values, ex: (1,5,7).For range of lines, use hyphen seperated values, ex: (1-5).You can combine both such as: ex: (1,5,10-15,20).
Overflow
Codeblock with constrained height for scrollable overflow behavior with long code.
Line Wrap
Comparison of line wrapping vs horizontal scrolling for long code lines in constrained widths.