Code Block
vel-src: components/code-block.css
A styled code display component with a header row for language badges, filenames, and copy buttons. Includes a terminal variant with macOS-style traffic-light dots.
| Class | Properties |
|---|---|
| vel-code-block | background: surface-0, border, border-radius: xl, overflow: hidden, font-family: mono |
| vel-code-block-header | flex row, space-between, background: surface-1, border-bottom, padding |
| vel-code-block-lang | purple pill badge — rgba primary bg, primary-300 text, border, border-radius: full |
| vel-code-block-filename | muted monospace filename, flex: 1 |
| vel-code-block-copy | copy button — border, rounded, hover: primary border + faint bg |
| vel-code-block-body | overflow-x: auto, padding |
| vel-code-block-line-numbers | adds generated line numbers via pseudo-element on the left |
| vel-code-block-terminal | terminal variant — header shows red/yellow/green macOS dots via ::before, code color: success-400 |
Examples
Standard code block with header
TS
tokens.ts
const tokens = {
color: {
primary: 'var(--vel-color-primary)',
success: 'var(--vel-color-success)',
},
space: {
4: 'var(--vel-space-4)',
8: 'var(--vel-space-8)',
},
}
Terminal variant
bash
$ npm install veloracss
$ npm run build
✓ Built dist/velora.css (42 kB)
✓ Built dist/velora.min.css (18 kB)