- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Code Block
Displays code, terminal output and diffs with an optional header, line numbers and a copy button.
import { Component, input } from '@angular/core';
@Component({
selector: 'app-hello',
template: `<p>Hello, {{ name() }}!</p>`,
})
export class HelloComponent {
readonly name = input('Angular');
}import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideDownload, lucideWrapText } from '@ng-icons/lucide';
import { HlmButton } from '@spartan-ng/helm/button';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-preview',
imports: [HlmCodeBlockImports, HlmButton, NgIcon],
providers: [provideIcons({ lucideDownload, lucideWrapText })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-lg">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>app/hello.component.ts</hlm-code-block-title>
<hlm-code-block-actions>
<button
hlmBtn
variant="ghost"
size="icon-xs"
aria-label="Wrap lines"
[attr.aria-pressed]="_wrap()"
(click)="_wrap.set(!_wrap())"
>
<ng-icon name="lucideWrapText" />
</button>
<button
hlmBtn
variant="ghost"
size="icon-xs"
aria-label="Download"
(click)="_download(_code, 'hello.component.ts')"
>
<ng-icon name="lucideDownload" />
</button>
<button hlmCodeBlockCopyButton [value]="_code"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_code" [wrap]="_wrap()"></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockPreview {
protected readonly _wrap = signal(false);
protected readonly _code = `import { Component, input } from '@angular/core';
@Component({
selector: 'app-hello',
template: \`<p>Hello, {{ name() }}!</p>\`,
})
export class HelloComponent {
readonly name = input('Angular');
}`;
protected _download(value: string, filename: string): void {
const url = URL.createObjectURL(new Blob([value], { type: 'text/plain' }));
const link = document.createElement('a');
link.href = url;
link.download = filename;
link.click();
URL.revokeObjectURL(url);
}
}Installation
ng g @spartan-ng/cli:ui code-block
npx nx g @spartan-ng/cli:ui code-block
Usage
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>Terminal</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="output"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="output"></pre>
</hlm-code-block>Examples
Basic
$ pnpm build
> ng build
✔ Browser application bundle generation complete.
Initial chunk files | Names | Raw size
polyfills.js | polyfills | 34.52 kB
main.js | main | 210.45 kB
Output location: dist/appimport { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-basic',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<pre hlmCodeBlockContent>{{ _output }}</pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockBasic {
protected readonly _output = `$ pnpm build
> ng build
✔ Browser application bundle generation complete.
Initial chunk files | Names | Raw size
polyfills.js | polyfills | 34.52 kB
main.js | main | 210.45 kB
Output location: dist/app`;
}Header
$ pnpm add -D @spartan-ng/cli
Packages: +14
Progress: resolved 412, reused 398, downloaded 14, added 14, done
Done in 2.8s using pnpm v10.18.0import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideTerminal } from '@ng-icons/lucide';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-header',
imports: [HlmCodeBlockImports, NgIcon],
providers: [provideIcons({ lucideTerminal })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>
<ng-icon name="lucideTerminal" />
Terminal
</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_command"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent>{{ _output }}</pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockHeader {
protected readonly _command = 'pnpm add -D @spartan-ng/cli';
protected readonly _output = `$ ${this._command}
Packages: +14
Progress: resolved 412, reused 398, downloaded 14, added 14, done
Done in 2.8s using pnpm v10.18.0`;
}Actions
$ pnpm lint
apps/web/src/app/message-list.component.ts
18:22 error Unsafe call of an `any` typed value @typescript-eslint/no-unsafe-call
42:7 warning 'scrollToBottom' is assigned a value but never used @typescript-eslint/no-unused-vars
✖ 2 problems (1 error, 1 warning)import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideDownload, lucideTerminal, lucideWrapText } from '@ng-icons/lucide';
import { HlmButton } from '@spartan-ng/helm/button';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-actions',
imports: [HlmCodeBlockImports, HlmButton, NgIcon],
providers: [provideIcons({ lucideTerminal, lucideWrapText, lucideDownload })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>
<ng-icon name="lucideTerminal" />
Terminal
</hlm-code-block-title>
<hlm-code-block-actions>
<button
hlmBtn
variant="ghost"
size="icon-xs"
aria-label="Wrap lines"
[attr.aria-pressed]="_wrap()"
(click)="_wrap.set(!_wrap())"
>
<ng-icon name="lucideWrapText" />
</button>
<button
hlmBtn
variant="ghost"
size="icon-xs"
aria-label="Download"
(click)="_download(_output, 'lint.log')"
>
<ng-icon name="lucideDownload" />
</button>
<button hlmCodeBlockCopyButton [value]="_output"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_output" [wrap]="_wrap()"></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockActions {
protected readonly _wrap = signal(false);
protected readonly _output = `$ pnpm lint
apps/web/src/app/message-list.component.ts
18:22 error Unsafe call of an \`any\` typed value @typescript-eslint/no-unsafe-call
42:7 warning 'scrollToBottom' is assigned a value but never used @typescript-eslint/no-unused-vars
✖ 2 problems (1 error, 1 warning)`;
protected _download(value: string, filename: string): void {
const url = URL.createObjectURL(new Blob([value], { type: 'text/plain' }));
const link = document.createElement('a');
link.href = url;
link.download = filename;
link.click();
URL.revokeObjectURL(url);
}
}Floating Actions
$ pnpm add @spartan-ng/brain
Progress: resolved 412, reused 398, downloaded 14, added 14, done
dependencies:
+ @angular/cdk 20.2.0
+ @spartan-ng/brain 1.0.0
+ @spartan-ng/helm 1.0.0
Done in 2.8s using pnpm v10.18.0import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-floating-actions',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_output"></button>
</hlm-code-block-actions>
<pre hlmCodeBlockContent [code]="_output"></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockFloatingActions {
protected readonly _output = `$ pnpm add @spartan-ng/brain
Progress: resolved 412, reused 398, downloaded 14, added 14, done
dependencies:
+ @angular/cdk 20.2.0
+ @spartan-ng/brain 1.0.0
+ @spartan-ng/helm 1.0.0
Done in 2.8s using pnpm v10.18.0`;
}Line Numbers
{ "name": "chat", "private": true, "scripts": { "start": "ng serve", "build": "ng build" }}import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-line-numbers',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<pre hlmCodeBlockContent [code]="_code" lineNumbers></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockLineNumbers {
protected readonly _code = `{
"name": "chat",
"private": true,
"scripts": {
"start": "ng serve",
"build": "ng build"
}
}`;
}Start Line
if (!this._session) { this._router.navigate(['/login']); }
return this._db.project.findMany({ where: { ownerId: this._session.userId }, orderBy: { updatedAt: 'desc' }, });}import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-start-line',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>app/dashboard/dashboard.component.ts</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_code"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_code" lineNumbers [startLine]="10"></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockStartLine {
protected readonly _code = ` if (!this._session) {
this._router.navigate(['/login']);
}
return this._db.project.findMany({
where: { ownerId: this._session.userId },
orderBy: { updatedAt: 'desc' },
});
}`;
}Wrap
Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Angular'. Current value: 'Angular 20'. Find more at https://angular.dev/errors/NG0100Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Angular'. Current value: 'Angular 20'. Find more at https://angular.dev/errors/NG0100import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-wrap',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="grid w-full max-w-md gap-4">
<hlm-code-block>
<pre hlmCodeBlockContent [code]="_output"></pre>
</hlm-code-block>
<hlm-code-block>
<pre hlmCodeBlockContent [code]="_output" wrap></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockWrap {
protected readonly _output = `Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Angular'. Current value: 'Angular 20'. Find more at https://angular.dev/errors/NG0100`;
}Highlighted Lines
{
"projects": {
"app": {
"architect": {
"build": {
"options": {
"outputPath": "dist/app",
"index": "src/index.html",
"browser": "src/main.ts"
}
}
}
}
}
}
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
type Line = { text: string; variant: 'default' | 'highlighted' };
@Component({
selector: 'spartan-code-block-highlighted-lines',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<pre hlmCodeBlockContent lineNumbers>
@for (line of _lines; track $index) {
<span hlmCodeBlockLine [variant]="line.variant">{{ line.text }}</span>
}
</pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockHighlightedLines {
protected readonly _lines: Line[] = [
{ text: '{', variant: 'default' },
{ text: ' "projects": {', variant: 'default' },
{ text: ' "app": {', variant: 'default' },
{ text: ' "architect": {', variant: 'default' },
{ text: ' "build": {', variant: 'default' },
{ text: ' "options": {', variant: 'default' },
{ text: ' "outputPath": "dist/app",', variant: 'highlighted' },
{ text: ' "index": "src/index.html",', variant: 'default' },
{ text: ' "browser": "src/main.ts"', variant: 'highlighted' },
{ text: ' }', variant: 'default' },
{ text: ' }', variant: 'default' },
{ text: ' }', variant: 'default' },
{ text: ' }', variant: 'default' },
{ text: ' }', variant: 'default' },
{ text: '}', variant: 'default' },
];
}Diff
export class GreetingComponent {
protected readonly greeting = "Hello, " + this.name;
protected readonly greeting = computed(() => `Hello, ${this.name()}! Welcome back.`);
readonly name = input('Angular');
}
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
type Line = { text: string; variant: 'default' | 'added' | 'removed' };
@Component({
selector: 'spartan-code-block-diff',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>app/greeting.component.ts</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_code"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent>
@for (line of _lines; track $index) {
<span hlmCodeBlockLine [variant]="line.variant">{{ line.text }}</span>
}
</pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockDiff {
protected readonly _lines: Line[] = [
{ text: 'export class GreetingComponent {', variant: 'default' },
{ text: ' protected readonly greeting = "Hello, " + this.name;', variant: 'removed' },
{
text: ' protected readonly greeting = computed(() => `Hello, ${this.name()}! Welcome back.`);',
variant: 'added',
},
{ text: " readonly name = input('Angular');", variant: 'default' },
{ text: '}', variant: 'default' },
];
protected readonly _code = this._lines.map((line) => line.text).join('\n');
}Height
[01] GET /api/health 200 in 12ms
[02] GET /api/health 200 in 19ms
[03] GET /api/health 200 in 26ms
[04] GET /api/health 200 in 33ms
[05] GET /api/health 200 in 40ms
[06] GET /api/health 200 in 47ms
[07] GET /api/health 200 in 14ms
[08] GET /api/health 200 in 21ms
[09] GET /api/health 200 in 28ms
[10] GET /api/health 200 in 35ms
[11] GET /api/health 200 in 42ms
[12] GET /api/health 200 in 49ms
[13] GET /api/health 200 in 16ms
[14] GET /api/health 200 in 23ms
[15] GET /api/health 200 in 30ms
[16] GET /api/health 200 in 37ms
[17] GET /api/health 200 in 44ms
[18] GET /api/health 200 in 51ms
[19] GET /api/health 200 in 18ms
[20] GET /api/health 200 in 25ms
[21] GET /api/health 200 in 32ms
[22] GET /api/health 200 in 39ms
[23] GET /api/health 200 in 46ms
[24] GET /api/health 200 in 53ms
[25] GET /api/health 200 in 20ms
[26] GET /api/health 200 in 27ms
[27] GET /api/health 200 in 34ms
[28] GET /api/health 200 in 41ms
[29] GET /api/health 200 in 48ms
[30] GET /api/health 200 in 55ms
[31] GET /api/health 200 in 22ms
[32] GET /api/health 200 in 29ms
[33] GET /api/health 200 in 36ms
[34] GET /api/health 200 in 43ms
[35] GET /api/health 200 in 50ms
[36] GET /api/health 200 in 57ms
[37] GET /api/health 200 in 24ms
[38] GET /api/health 200 in 31ms
[39] GET /api/health 200 in 38ms
[40] GET /api/health 200 in 45msimport { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-height',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>Logs</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_logs"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_logs" class="scroll-fade-y max-h-64"></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockHeight {
protected readonly _logs = Array.from(
{ length: 40 },
(_, index) =>
`[${String(index + 1).padStart(2, '0')}] GET /api/health 200 in ${12 + Math.floor(index / 6) * 2 + (index % 6) * 7}ms`,
).join('\n');
}Size
$ pnpm add @spartan-ng/brain
Progress: resolved 412, reused 398, downloaded 14, added 14, done
Done in 2.8s using pnpm v10.18.0$ pnpm add @spartan-ng/brain
Progress: resolved 412, reused 398, downloaded 14, added 14, done
Done in 2.8s using pnpm v10.18.0import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideTerminal } from '@ng-icons/lucide';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-size',
imports: [HlmCodeBlockImports, NgIcon],
providers: [provideIcons({ lucideTerminal })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="grid w-full max-w-md gap-4">
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>
<ng-icon name="lucideTerminal" />
Terminal
</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_output"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_output"></pre>
</hlm-code-block>
<hlm-code-block size="sm">
<hlm-code-block-header>
<hlm-code-block-title>
<ng-icon name="lucideTerminal" />
Terminal
</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_output"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_output" wrap></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockSize {
protected readonly _output = `$ pnpm add @spartan-ng/brain
Progress: resolved 412, reused 398, downloaded 14, added 14, done
Done in 2.8s using pnpm v10.18.0`;
}Destructive
TypeError: Cannot read properties of undefined (reading 'pipe')
at MessageListComponent.ngOnInit (app/message-list.component.ts:18:22)
at callHook (core.mjs:16305:18)import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-destructive',
imports: [HlmCodeBlockImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="w-full max-w-md">
<hlm-code-block variant="destructive">
<hlm-code-block-header>
<hlm-code-block-title>Error</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_error"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_error" wrap></pre>
</hlm-code-block>
</div>
`,
})
export class CodeBlockDestructive {
protected readonly _error = `TypeError: Cannot read properties of undefined (reading 'pipe')
at MessageListComponent.ngOnInit (app/message-list.component.ts:18:22)
at callHook (core.mjs:16305:18)`;
}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
ثبّت الحزم، ثم شغّل خادم التطوير.
pnpm add @spartan-ng/brain
pnpm startimport { Directionality } from '@angular/cdk/bidi';
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmCodeBlockImports } from '@spartan-ng/helm/code-block';
@Component({
selector: 'spartan-code-block-rtl-preview',
imports: [HlmCodeBlockImports],
providers: [Directionality],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full max-w-md',
'[dir]': '_dir()',
},
template: `
<p class="text-muted-foreground mb-4 text-sm">{{ _t()['intro'] }}</p>
<hlm-code-block>
<hlm-code-block-header>
<hlm-code-block-title>{{ _t()['title'] }}</hlm-code-block-title>
<hlm-code-block-actions>
<button hlmCodeBlockCopyButton [value]="_output"></button>
</hlm-code-block-actions>
</hlm-code-block-header>
<pre hlmCodeBlockContent [code]="_output"></pre>
</hlm-code-block>
`,
})
export class CodeBlockRtlPreview {
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
intro: 'Install the packages, then run the dev server.',
title: 'Terminal',
},
},
ar: {
dir: 'rtl',
values: {
intro: 'ثبّت الحزم، ثم شغّل خادم التطوير.',
title: 'الطرفية',
},
},
he: {
dir: 'rtl',
values: {
intro: 'התקן את החבילות, ואז הפעל את שרת הפיתוח.',
title: 'מסוף',
},
},
};
protected readonly _output = `pnpm add @spartan-ng/brain
pnpm start`;
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
}Helm API
HlmCodeBlockActions
Selector: [hlmCodeBlockActions],hlm-code-block-actions
ExportAs: hlmCodeBlockActions
HlmCodeBlockContent
Selector: pre[hlmCodeBlockContent]
ExportAs: hlmCodeBlockContent
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| wrap | boolean | false | - |
| lineNumbers | boolean | false | - |
| startLine | number | 1 | - |
| code | string | - | When set, the code is rendered line by line instead of projecting `<ng-content />`. |
HlmCodeBlockCopyButton
Selector: button[hlmCodeBlockCopyButton]
ExportAs: hlmCodeBlockCopyButton
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | '' | - |
| copyText | string | 'Copy' | - |
| copiedText | string | 'Copied' | - |
| variant | ButtonVariants['variant'] | this._config.variant | - |
| size | ButtonVariants['size'] | this._config.size | - |
HlmCodeBlockFooter
Selector: [hlmCodeBlockFooter],hlm-code-block-footer
ExportAs: hlmCodeBlockFooter
HlmCodeBlockHeader
Selector: [hlmCodeBlockHeader],hlm-code-block-header
ExportAs: hlmCodeBlockHeader
HlmCodeBlockLine
Selector: span[hlmCodeBlockLine]
ExportAs: hlmCodeBlockLine
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | CodeBlockLineVariants['variant'] | 'default' | - |
HlmCodeBlockTitle
Selector: [hlmCodeBlockTitle],hlm-code-block-title
ExportAs: hlmCodeBlockTitle
HlmCodeBlock
Selector: [hlmCodeBlock],hlm-code-block
ExportAs: hlmCodeBlock
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | CodeBlockVariants['variant'] | 'default' | - |
| size | 'default' | 'sm' | 'default' | - |
On This Page