Skip to main content
VelinStyle v0.9.0
⌂ Home
  1. Docs
  2. Components
  3. Code block

Code block 0.9.0

The <velin-code-block> Web Component wraps source text with VelinHighlight token colors, optional line numbers, line highlights, copy, and collapse.

See also Syntax highlighting guide and generated velin-code-block.md.

Basic

const greet = (name) => `Hello, ${name}!`; console.log(greet('Velin'));
<velin-code-block language="js" line-numbers>
const greet = (name) => `Hello, ${name}!`;
</velin-code-block>

Attributes

AttributeNotes
languageLexer id: js, ts, html, css, php, blade, …
line-numbersShow gutter numbers
highlightRanges e.g. 1-2,5
collapsedToolbar expand/collapse

Line highlights

.btn { padding: 0.5rem 1rem; } .btn--primary { background: var(--velin-color-primary); }

Loading

import { register, bootFromDOM } from '@birdapi/velinstyle';
await register(['velin-code-block', 'velin-copy']);
await bootFromDOM(document, { highlight: true });