Code

A structured code container with an optional header bar showing filename, language badge, and copy button. Syntax tokens are defined as custom properties so any highlighter can use them.

Default

index.htmlhtml
<div class="ln-code">
  <div class="ln-code__header">
    <span class="ln-code__filename">index.js</span>
    <span class="ln-code__lang">JS</span>
  </div>
  <pre class="ln-code__body"><code>function greet(name) {
  return `Hello, ${name}!`;
}

export default greet;</code></pre>
</div>
index.jsJS
function greet(name) {
  return `Hello, ${name}!`;
}

export default greet;

Flush variant

The --flush modifier removes border-radius and bottom margin for embedding inside other containers.

index.htmlhtml
<div class="ln-code ln-code--flush">
  <pre class="ln-code__body"><code>npm install ln</code></pre>
</div>
npm install ln

Reference

ClassDescriptionResponsive
.ln-codeCode block container with syntax highlightingNo
.ln-code__headerFile name and language label barNo
.ln-code__langLanguage label in the headerNo
.ln-code__bodyScrollable code area (<pre>)No
.ln-code__lineIndividual line with line numberNo
.ln-code__line--highlightHighlighted line with accent borderNo
.ln-code--wrapEnable word wrappingNo
.ln-code--flushRemove border-radius and bottom marginNo