Enhances a native textarea with syntax highlighting while preserving native editing and form behavior.
<nve-code-textarea language="typescript">
<label>Source code</label>
<textarea name="source" rows="8" spellcheck="false">
const gpus = [
{ name: 'B200', specs: { architecture: 'Blackwell' } },
{ name: 'H100 SXM5', specs: { architecture: 'Hopper' } }
] as const;
export const blackwellGpus = gpus.filter(gpu =>
gpu.specs.architecture.startsWith('Blackwell')
);</textarea>
</nve-code-textarea>
Source code
Syntax highlighting a textarea requires browser support for
OpaqueRange. Editing and form submission still work without it. See the
Open UI explainer .
Installation Note: Import the languages you need before defining the component.
import '@nvidia-elements/code/languages/typescript.js';
import '@nvidia-elements/code/code-textarea/define.js'; Embedded Languages Highlight source across languages, from Markdown and fenced JavaScript to tagged HTML and CSS templates.
<nve-code-textarea language="markdown">
<label>Markdown source</label>
<textarea name="markdown" rows="10" spellcheck="false">
# Release notes
Show the current build status.
~~~javascript
const status = "Ready";
const badge = html`<span class="status">${status}</span>`;
const styles = css`.status { color: seagreen; }`;
~~~</textarea>
</nve-code-textarea>
Markdown source
Bracket Pair Coloring Make nested expressions easier to follow by giving matching brackets the same color.
<nve-code-textarea language="typescript" bracket-pair-coloring>
<label>Nested TypeScript</label>
<textarea name="source" rows="8" spellcheck="false">
const gpus = [
{ name: 'B200', specs: { architecture: 'Blackwell' } },
{ name: 'H100 SXM5', specs: { architecture: 'Hopper' } }
] as const;
export const blackwellGpus = gpus.filter(gpu =>
gpu.specs.architecture.startsWith('Blackwell')
);</textarea>
</nve-code-textarea>
Nested TypeScript
Flat Fit highlighted source into the surrounding surface.
<nve-code-textarea language="typescript" container="flat">
<label>Source code</label>
<textarea name="source" rows="8" spellcheck="false">
const gpus = [
{ name: 'B200', specs: { architecture: 'Blackwell' } },
{ name: 'H100 SXM5', specs: { architecture: 'Hopper' } }
] as const;
export const blackwellGpus = gpus.filter(gpu =>
gpu.specs.architecture.startsWith('Blackwell')
);</textarea>
</nve-code-textarea>
Source code
Submit and reset a highlighted JSON field with native required-field validation.
<form id="code-textarea-form" nve-layout="column gap:md align:horizontal-stretch">
<nve-code-textarea language="json">
<label>Configuration</label>
<textarea name="configuration" rows="5" required spellcheck="false">
{
"gpu": "B200",
"batchSize": 16,
"precision": "fp16"
}</textarea>
</nve-code-textarea>
<div nve-layout="row gap:xs">
<nve-button type="submit">Submit</nve-button>
<nve-button type="reset">Reset</nve-button>
</div>
</form>
<script type="module">
const form = document.querySelector("#code-textarea-form");
form.addEventListener("submit", (event) => {
event.preventDefault();
console.log("submit", Object.fromEntries(new FormData(form)));
});
</script>
Release Status All elements and features go through 3 phases of stability, pre-release, beta and stable.
pre-release Docs Preview API Documentation Fully Themeable
beta Robust unit test coverages Passed API Review Passed Designer VQA Review Included in library package stable No known outstanding AA WCAG issues No known outstanding performance issues Adapts to different screen/container sizes No breaking API changes for at least 90 days