A container for content representing programming languages.
Installation
Note: import the language before the codeblock
// only import languages that you need
import '@nvidia-elements/code/codeblock/languages/bash.js';
import '@nvidia-elements/code/codeblock/languages/css.js';
import '@nvidia-elements/code/codeblock/languages/go.js';
import '@nvidia-elements/code/codeblock/languages/html.js';
import '@nvidia-elements/code/codeblock/languages/javascript.js';
import '@nvidia-elements/code/codeblock/languages/json.js';
import '@nvidia-elements/code/codeblock/languages/markdown.js';
import '@nvidia-elements/code/codeblock/languages/python.js';
import '@nvidia-elements/code/codeblock/languages/toml.js';
import '@nvidia-elements/code/codeblock/languages/typescript.js';
import '@nvidia-elements/code/codeblock/languages/xml.js';
import '@nvidia-elements/code/codeblock/languages/yaml.js';
// import component
import '@nvidia-elements/code/codeblock/define.js';
<nve-codeblock language="typescript">
function getTime(): number {
return new Date().getTime();
}
</nve-codeblock>
Code
Text code to be process into a codeblock.
Codeblock using the code property for programmatic/dynamic usage.
Container
Determines the container styles of component. Flat enables nesting within other containers.
Codeblock with flat container styling for minimal visual emphasis.
Theme
You can set a Theme independent of the global theme using the nve-theme attribute.
Light and dark theme variations for different UI contexts.
Line Numbers
Adds styling to show the line numbers of the codeblock.
Codeblock with line numbers for easier code reference and debugging.
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).
Codeblock with specific line highlighting to draw attention to important code sections.
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.
Release Status
All elements and features go through 3 phases of stability, pre-release, beta and stable.