Getting Started
UI
Components
- 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
Utilities
Forms
Stack
Kbd
Used to display textual user input from keyboard.
⌘⇧⌥⌃Ctrl+B
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-kbd-preview',
imports: [HlmKbdImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex flex-col items-center gap-4">
<kbd hlmKbdGroup>
<kbd hlmKbd>⌘</kbd>
<kbd hlmKbd>⇧</kbd>
<kbd hlmKbd>⌥</kbd>
<kbd hlmKbd>⌃</kbd>
</kbd>
<kbd hlmKbdGroup>
<kbd hlmKbd>Ctrl</kbd>
<span>+</span>
<kbd hlmKbd>B</kbd>
</kbd>
</div>
`,
})
export class KbdPreview {}Installation
ng g @spartan-ng/cli:ui kbdnx g @spartan-ng/cli:ui kbdUsage
import { HlmKbdImports } from '@spartan-ng/helm/kbd';<kbd hlmKbd>⌘</kbd>Examples
Group
Use the HlmKbdGroup component to group keyboard keys together.
Use Ctrl + BCtrl + K to open the command palette
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-kbd-group-preview',
imports: [HlmKbdImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex flex-col items-center gap-4">
<p class="text-muted-foreground text-sm">
Use
<kbd hlmKbdGroup>
<kbd hlmKbd>Ctrl + B</kbd>
<kbd hlmKbd>Ctrl + K</kbd>
</kbd>
to open the command palette
</p>
</div>
`,
})
export class KbdGroupPreview {}Button
Use the HlmKbd component inside a HlmBtn to display a keyboard key inside a button.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-kbd-button-preview',
imports: [HlmKbdImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex flex-wrap items-center gap-4">
<button hlmBtn variant="outline" size="sm" class="pr-2">
Accept
<kbd hlmKbd>⏎</kbd>
</button>
<button hlmBtn variant="outline" size="sm" class="pr-2">
Cancel
<kbd hlmKbd>Esc</kbd>
</button>
</div>
`,
})
export class KbdButtonPreview {}Input Group
Use the HlmKbd component inside a HlmInputGroupAddon to display a keyboard key inside an input group.
⌘K
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideSearch } from '@ng-icons/lucide';
import { HlmInputGroupImports } from '@spartan-ng/helm/input-group';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-kbd-input-group-preview',
imports: [HlmKbdImports, HlmInputGroupImports, NgIcon],
providers: [provideIcons({ lucideSearch })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex w-full max-w-xs flex-col gap-6">
<div hlmInputGroup>
<input hlmInputGroupInput placeholder="Search..." />
<div hlmInputGroupAddon>
<ng-icon name="lucideSearch" />
</div>
<div hlmInputGroupAddon align="inline-end">
<kbd hlmKbd>⌘</kbd>
<kbd hlmKbd>K</kbd>
</div>
</div>
</div>
`,
})
export class KbdInputGroupPreview {}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
⌘⇧⌥⌃Ctrl+B
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-kbd-rtl-preview',
imports: [HlmKbdImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="flex flex-col items-center gap-4" [dir]="_dir()">
<kbd hlmKbdGroup>
<kbd hlmKbd>⌘</kbd>
<kbd hlmKbd>⇧</kbd>
<kbd hlmKbd>⌥</kbd>
<kbd hlmKbd>⌃</kbd>
</kbd>
<kbd hlmKbdGroup>
<kbd hlmKbd>Ctrl</kbd>
<span>+</span>
<kbd hlmKbd>B</kbd>
</kbd>
</div>
`,
})
export class KbdRtlPreview {
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {},
},
ar: {
dir: 'rtl',
values: {},
},
he: {
dir: 'rtl',
values: {},
},
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _dir = computed(() => this._translation().dir);
}Helm API
HlmKbdGroup
Selector: kbd[hlmKbdGroup]
ExportAs: hlmKbdGroup
HlmKbd
Selector: kbd[hlmKbd]
ExportAs: hlmKbd
On This Page
Stop configuring. Start shipping.
Zerops powers spartan.ng and Angular teams worldwide.
One-command deployment. Zero infrastructure headaches.
Deploy with Zerops