- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Dropdown Menu
- Empty
- Field
- Hover Card
- Icon
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
Command
Fast, composable, command menu for Angular.
import { Component } from '@angular/core';
import { provideIcons } from '@ng-icons/core';
import {
lucideCalculator,
lucideCalendar,
lucideCog,
lucidePlus,
lucideSearch,
lucideSmile,
lucideUser,
lucideWallet,
} from '@ng-icons/lucide';
import { HlmCommandImports } from '@spartan-ng/helm/command';
import { HlmIconImports } from '@spartan-ng/helm/icon';
@Component({
selector: 'spartan-command-preview',
imports: [HlmCommandImports, HlmIconImports],
providers: [
provideIcons({
lucideSearch,
lucideCalendar,
lucideSmile,
lucidePlus,
lucideUser,
lucideWallet,
lucideCog,
lucideCalculator,
}),
],
host: {
class: 'block w-full',
},
template: `
<hlm-command class="rounded-lg border shadow-md md:min-w-[450px]">
<hlm-command-input placeholder="Type a command or search..." />
<hlm-command-list>
<div *hlmCommandEmptyState hlmCommandEmpty>No results found.</div>
<hlm-command-group>
<hlm-command-group-label>Suggestions</hlm-command-group-label>
<button hlm-command-item value="Calendar">
<ng-icon name="lucideCalendar" />
Calendar
</button>
<button hlm-command-item value="Search Emoji">
<ng-icon name="lucideSmile" />
Search Emoji
</button>
<button hlm-command-item value="Calculator" disabled>
<ng-icon name="lucideCalculator" />
Calculator
</button>
</hlm-command-group>
<hlm-command-separator />
<hlm-command-group>
<hlm-command-group-label>Settings</hlm-command-group-label>
<button hlm-command-item value="Profile">
<ng-icon name="lucideUser" />
Profile
<hlm-command-shortcut>⌘P</hlm-command-shortcut>
</button>
<button hlm-command-item value="Billing">
<ng-icon name="lucideWallet" />
Billing
<hlm-command-shortcut>⌘B</hlm-command-shortcut>
</button>
<button hlm-command-item value="Settings">
<ng-icon name="lucideCog" />
Settings
<hlm-command-shortcut>⌘S</hlm-command-shortcut>
</button>
</hlm-command-group>
</hlm-command-list>
</hlm-command>
`,
})
export class CommandPreview {}Installation
ng g @spartan-ng/cli:ui commandnx g @spartan-ng/cli:ui commandimport { DestroyRef, ElementRef, HostAttributeToken, Injector, PLATFORM_ID, effect, inject, runInInjectionContext } from '@angular/core';
import { clsx, type ClassValue } from 'clsx';
import { isPlatformBrowser } from '@angular/common';
import { twMerge } from 'tailwind-merge';
export function hlm(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
// Global map to track class managers per element
const elementClassManagers = new WeakMap<HTMLElement, ElementClassManager>();
// Global mutation observer for all elements
let globalObserver: MutationObserver | null = null;
const observedElements = new Set<HTMLElement>();
interface ElementClassManager {
element: HTMLElement;
sources: Map<number, { classes: Set<string>; order: number }>;
baseClasses: Set<string>;
isUpdating: boolean;
nextOrder: number;
hasInitialized: boolean;
restoreRafId: number | null;
/** Transitions are suppressed until the first effect writes correct classes */
transitionsSuppressed: boolean;
/** Original inline transition value to restore after suppression (empty string = none was set) */
previousTransition: string;
/** Original inline transition priority to preserve !important when restoring */
previousTransitionPriority: string;
}
let sourceCounter = 0;
/**
* This function dynamically adds and removes classes for a given element without requiring
* the a class binding (e.g. `[class]="..."`) which may interfere with other class bindings.
*
* 1. This will merge the existing classes on the element with the new classes.
* 2. It will also remove any classes that were previously added by this function but are no longer present in the new classes.
* 3. Multiple calls to this function on the same element will be merged efficiently.
*/
export function classes(computed: () => ClassValue[] | string, options: ClassesOptions = {}) {
runInInjectionContext(options.injector ?? inject(Injector), () => {
const elementRef = options.elementRef ?? inject(ElementRef);
const platformId = inject(PLATFORM_ID);
const destroyRef = inject(DestroyRef);
const baseClasses = inject(new HostAttributeToken('class'), { optional: true });
const element = elementRef.nativeElement;
// Create unique identifier for this source
const sourceId = sourceCounter++;
// Get or create the class manager for this element
let manager = elementClassManagers.get(element);
if (!manager) {
// Initialize base classes from variation (host attribute 'class')
const initialBaseClasses = new Set<string>();
if (baseClasses) {
toClassList(baseClasses).forEach((cls) => initialBaseClasses.add(cls));
}
manager = {
element,
sources: new Map(),
baseClasses: initialBaseClasses,
isUpdating: false,
nextOrder: 0,
hasInitialized: false,
restoreRafId: null,
transitionsSuppressed: false,
previousTransition: '',
previousTransitionPriority: '',
};
elementClassManagers.set(element, manager);
// Setup global observer if needed and register this element
setupGlobalObserver(platformId);
observedElements.add(element);
// Suppress transitions until the first effect writes correct classes and
// the browser has painted them. This prevents CSS transition animations
// during hydration when classes change from SSR state to client state.
if (isPlatformBrowser(platformId)) {
manager.previousTransition = element.style.getPropertyValue('transition');
manager.previousTransitionPriority = element.style.getPropertyPriority('transition');
element.style.setProperty('transition', 'none', 'important');
manager.transitionsSuppressed = true;
}
}
// Assign order once at registration time
const sourceOrder = manager.nextOrder++;
function updateClasses(): void {
// Get the new classes from the computed function
const newClasses = toClassList(computed());
// Update this source's classes, keeping the original order
manager!.sources.set(sourceId, {
classes: new Set(newClasses),
order: sourceOrder,
});
// Update the element
updateElement(manager!);
// Re-enable transitions after the first effect writes correct classes.
// Deferred to next animation frame so the browser paints the class change
// with transitions disabled first, then re-enables them.
if (manager!.transitionsSuppressed) {
manager!.transitionsSuppressed = false;
manager!.restoreRafId = requestAnimationFrame(() => {
manager!.restoreRafId = null;
restoreTransitionSuppression(manager!);
});
}
}
// Register cleanup with DestroyRef
destroyRef.onDestroy(() => {
if (manager!.restoreRafId !== null) {
cancelAnimationFrame(manager!.restoreRafId);
manager!.restoreRafId = null;
}
if (manager!.transitionsSuppressed) {
manager!.transitionsSuppressed = false;
restoreTransitionSuppression(manager!);
}
// Remove this source from the manager
manager!.sources.delete(sourceId);
// If no more sources, clean up the manager
if (manager!.sources.size === 0) {
cleanupManager(element);
} else {
// Update element without this source's classes
updateElement(manager!);
}
});
/**
* We need this effect to track changes to the computed classes. Ideally, we would use
* afterRenderEffect here, but that doesn't run in SSR contexts, so we use a standard
* effect which works in both browser and SSR.
*/
effect(updateClasses);
});
}
function restoreTransitionSuppression(manager: ElementClassManager): void {
const prev = manager.previousTransition;
if (prev) {
manager.element.style.setProperty('transition', prev, manager.previousTransitionPriority || undefined);
} else {
manager.element.style.removeProperty('transition');
}
}
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
function setupGlobalObserver(platformId: Object): void {
if (isPlatformBrowser(platformId) && !globalObserver) {
// Create single global observer that watches the entire document
globalObserver = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
const element = mutation.target as HTMLElement;
const manager = elementClassManagers.get(element);
// Only process elements we're managing
if (manager && observedElements.has(element)) {
if (manager.isUpdating) continue; // Ignore changes we're making
// Update base classes to include any externally added classes
const currentClasses = toClassList(element.className);
const allSourceClasses = new Set<string>();
// Collect all classes from all sources
for (const source of manager.sources.values()) {
for (const className of source.classes) {
allSourceClasses.add(className);
}
}
// Any classes not from sources become new base classes
manager.baseClasses.clear();
for (const className of currentClasses) {
if (!allSourceClasses.has(className)) {
manager.baseClasses.add(className);
}
}
updateElement(manager);
}
}
}
});
// Start observing the entire document for class attribute changes
globalObserver.observe(document, {
attributes: true,
attributeFilter: ['class'],
subtree: true, // Watch all descendants
});
}
}
function updateElement(manager: ElementClassManager): void {
if (manager.isUpdating) return; // Prevent recursive updates
manager.isUpdating = true;
// Handle initialization: capture base classes after first source registration
if (!manager.hasInitialized && manager.sources.size > 0) {
// Get current classes on element (may include SSR classes)
const currentClasses = toClassList(manager.element.className);
// Get all classes that will be applied by sources
const allSourceClasses = new Set<string>();
for (const source of manager.sources.values()) {
source.classes.forEach((className) => allSourceClasses.add(className));
}
// Only consider classes as "base" if they're not produced by any source
// This prevents SSR-rendered classes from being preserved as base classes
currentClasses.forEach((className) => {
if (!allSourceClasses.has(className)) {
manager.baseClasses.add(className);
}
});
manager.hasInitialized = true;
}
// Get classes from all sources, sorted by registration order (later takes precedence)
const sortedSources = Array.from(manager.sources.entries()).sort(([, a], [, b]) => a.order - b.order);
const allSourceClasses: string[] = [];
for (const [, source] of sortedSources) {
allSourceClasses.push(...source.classes);
}
// Combine base classes with all source classes, ensuring base classes take precedence
const classesToApply =
allSourceClasses.length > 0 || manager.baseClasses.size > 0
? hlm([...allSourceClasses, ...manager.baseClasses])
: '';
// Apply the classes to the element
if (manager.element.className !== classesToApply) {
manager.element.className = classesToApply;
}
manager.isUpdating = false;
}
function cleanupManager(element: HTMLElement): void {
// Remove from global tracking
observedElements.delete(element);
elementClassManagers.delete(element);
// If no more elements being tracked, cleanup global observer
if (observedElements.size === 0 && globalObserver) {
globalObserver.disconnect();
globalObserver = null;
}
}
interface ClassesOptions {
elementRef?: ElementRef<HTMLElement>;
injector?: Injector;
}
// Cache for parsed class lists to avoid repeated string operations
const classListCache = new Map<string, string[]>();
function toClassList(className: string | ClassValue[]): string[] {
// For simple string inputs, use cache to avoid repeated parsing
if (typeof className === 'string' && classListCache.has(className)) {
return classListCache.get(className)!;
}
const result = clsx(className)
.split(' ')
.filter((c) => c.length > 0);
// Cache string results, but limit cache size to prevent memory growth
if (typeof className === 'string' && classListCache.size < 1000) {
classListCache.set(className, result);
}
return result;
}import { BooleanInput } from '@angular/cdk/coercion';
import { BrnCommand, BrnCommandEmpty, BrnCommandGroup, BrnCommandInput, BrnCommandItem, BrnCommandList, BrnCommandSeparator } from '@spartan-ng/brain/command';
import { BrnDialogContent, BrnDialogState } from '@spartan-ng/brain/dialog';
import { ChangeDetectionStrategy, Component, Directive, booleanAttribute, computed, input, linkedSignal, output } from '@angular/core';
import { ClassValue } from 'clsx';
import { HlmDialogImports } from '@spartan-ng/helm/dialog';
import { HlmInputGroupImports } from '@spartan-ng/helm/input-group';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { classes, hlm } from '@spartan-ng/helm/utils';
import { lucideSearch } from '@ng-icons/lucide';
@Component({
selector: 'hlm-command-dialog',
imports: [HlmDialogImports, BrnDialogContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-dialog [state]="_state()" (stateChanged)="stateChanged($event)">
<hlm-dialog-content
*hlmDialogPortal="let ctx"
[class]="_computedDialogContentClass()"
[showCloseButton]="showCloseButton()"
>
<hlm-dialog-header class="sr-only">
<h2 hlmDialogTitle>{{ title() }}</h2>
<p hlmDialogDescription>{{ description() }}</p>
</hlm-dialog-header>
<ng-content />
</hlm-dialog-content>
</hlm-dialog>
`,
})
export class HlmCommandDialog {
public readonly title = input<string>('Command Palette');
public readonly description = input<string>('Search for a command to run...');
public readonly state = input<BrnDialogState>('closed');
protected readonly _state = linkedSignal(this.state);
public readonly showCloseButton = input<boolean, BooleanInput>(false, { transform: booleanAttribute });
public readonly dialogContentClass = input<ClassValue>('');
protected readonly _computedDialogContentClass = computed(() => hlm('w-96 p-0', this.dialogContentClass()));
public readonly stateChange = output<BrnDialogState>();
protected stateChanged(state: BrnDialogState) {
this.stateChange.emit(state);
this._state.set(state);
}
}
@Directive({
selector: '[hlmCommandEmptyState]',
hostDirectives: [BrnCommandEmpty],
})
export class HlmCommandEmptyState {}
@Directive({
selector: '[hlmCommandEmpty]',
host: {
'data-slot': 'command-empty',
},
})
export class HlmCommandEmpty {
constructor() {
classes(() => 'py-6 text-center text-sm');
}
}
@Directive({
selector: '[hlmCommandGroupLabel],hlm-command-group-label',
host: {
'data-slot': 'command-group-label',
role: 'presentation',
},
})
export class HlmCommandGroupLabel {
constructor() {
classes(() => 'text-muted-foreground block px-2 py-1.5 text-xs font-medium');
}
}
@Directive({
selector: '[hlmCommandGroup],hlm-command-group',
hostDirectives: [
{
directive: BrnCommandGroup,
inputs: ['id'],
},
],
host: {
'data-slot': 'command-group',
},
})
export class HlmCommandGroup {
constructor() {
classes(() => 'text-foreground block overflow-hidden p-1 data-hidden:hidden');
}
}
@Component({
selector: 'hlm-command-input',
imports: [HlmInputGroupImports, NgIcon, BrnCommandInput],
providers: [provideIcons({ lucideSearch })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-input-group
class="bg-input/30 border-input/30 h-8 rounded-lg shadow-none *:data-[slot=input-group-addon]:pl-2"
>
<input
brnCommandInput
data-slot="command-input"
class="w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
[id]="id()"
[placeholder]="placeholder()"
/>
<hlm-input-group-addon>
<ng-icon name="lucideSearch" />
</hlm-input-group-addon>
</hlm-input-group>
`,
})
export class HlmCommandInput {
public readonly id = input<string | undefined>();
public readonly placeholder = input<string>('');
constructor() {
classes(() => 'p-1 pb-0');
}
}
@Directive({
selector: 'button[hlmCommandItem],button[hlm-command-item]',
hostDirectives: [
{
directive: BrnCommandItem,
inputs: ['value', 'disabled', 'id'],
outputs: ['selected'],
},
],
host: {
'data-slot': 'command-item',
},
})
export class HlmCommandItem {
constructor() {
classes(
() =>
"data-[selected]:bg-accent data-[selected=true]:text-accent-foreground [&>ng-icon:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-hidden:hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>ng-icon]:pointer-events-none [&>ng-icon]:shrink-0 [&>ng-icon:not([class*='text-'])]:text-base",
);
}
}
@Directive({
selector: '[hlmCommandList],hlm-command-list',
hostDirectives: [
{
directive: BrnCommandList,
inputs: ['id'],
},
],
host: {
'data-slot': 'command-list',
},
})
export class HlmCommandList {
constructor() {
classes(() => 'no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none');
}
}
@Directive({
selector: '[hlmCommandSeparator],hlm-command-separator',
hostDirectives: [BrnCommandSeparator],
host: {
'data-slot': 'command-separator',
},
})
export class HlmCommandSeparator {
constructor() {
classes(() => 'bg-border -mx-1 block h-px w-auto data-hidden:hidden');
}
}
@Directive({
selector: '[hlmCommandShortcut],hlm-command-shortcut',
host: {
'data-slot': 'command-shortcut',
},
})
export class HlmCommandShortcut {
constructor() {
classes(() => 'text-muted-foreground ml-auto text-xs tracking-widest');
}
}
@Directive({
selector: '[hlmCommand],hlm-command',
hostDirectives: [
{
directive: BrnCommand,
inputs: ['id', 'filter', 'search', 'disabled'],
outputs: ['valueChange', 'searchChange'],
},
],
host: {
'data-slot': 'command',
},
})
export class HlmCommand {
constructor() {
classes(() => 'bg-popover text-popover-foreground flex size-full flex-col overflow-hidden rounded-xl p-1');
}
}
export const HlmCommandImports = [
HlmCommand,
HlmCommandDialog,
HlmCommandEmpty,
HlmCommandEmptyState,
HlmCommandGroup,
HlmCommandGroupLabel,
HlmCommandInput,
HlmCommandItem,
HlmCommandList,
HlmCommandSeparator,
HlmCommandShortcut,
] as const;Usage
import { HlmCommandImports } from '@spartan-ng/helm/command';<hlm-command>
<hlm-command-input placeholder="Type a command or search..." />
<hlm-command-list>
<div *hlmCommandEmptyState hlmCommandEmpty>No results found.</div>
<hlm-command-group>
<hlm-command-group-label>Suggestions</hlm-command-group-label>
<button hlm-command-item value="Calendar">
<ng-icon name="lucideCalendar" />
Calendar
</button>
</hlm-command-group>
<hlm-command-separator />
<hlm-command-group>
<hlm-command-group-label>Settings</hlm-command-group-label>
<button hlm-command-item value="Profile">
<ng-icon name="lucideUser" />
Profile
<hlm-command-shortcut>⌘P</hlm-command-shortcut>
</button>
</hlm-command-group>
</hlm-command-list>
</hlm-command>Examples
Dialog
Press ⌘ + J
Last command: none
import { Component, signal } from '@angular/core';
import { provideIcons } from '@ng-icons/core';
import {
lucideCalendar,
lucideCog,
lucideLayers,
lucidePlus,
lucideSearch,
lucideSmile,
lucideUser,
lucideX,
} from '@ng-icons/lucide';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCommandImports } from '@spartan-ng/helm/command';
import { HlmIconImports } from '@spartan-ng/helm/icon';
import { HlmKbdImports } from '@spartan-ng/helm/kbd';
@Component({
selector: 'spartan-command-dialog',
imports: [HlmCommandImports, HlmIconImports, HlmButtonImports, HlmKbdImports],
providers: [
provideIcons({
lucideX,
lucideCalendar,
lucideSmile,
lucidePlus,
lucideUser,
lucideLayers,
lucideCog,
lucideSearch,
}),
],
host: {
'(window:keydown)': 'onKeyDown($event)',
},
template: `
<div class="mx-auto flex max-w-screen-sm items-center justify-center space-x-4 py-20 text-sm">
<p>
Press
<kbd hlmKbd>⌘ + J</kbd>
</p>
<p>
Last command:
<code data-testid="lastCommand" hlmCode>{{ command() || 'none' }}</code>
</p>
</div>
<hlm-command-dialog [state]="state()" (stateChange)="stateChanged($event)">
<hlm-command>
<hlm-command-input placeholder="Type a command or search..." />
<hlm-command-list>
<div *hlmCommandEmptyState hlmCommandEmpty>No results found.</div>
<hlm-command-group>
<hlm-command-group-label>Suggestions</hlm-command-group-label>
<button hlm-command-item value="calendar" (selected)="commandSelected('calendar')">
<ng-icon name="lucideCalendar" />
Calendar
</button>
<button hlm-command-item value="emojy" (selected)="commandSelected('emojy')">
<ng-icon name="lucideSmile" />
Search Emoji
</button>
<button hlm-command-item value="calculator" (selected)="commandSelected('calculator')">
<ng-icon name="lucidePlus" />
Calculator
</button>
</hlm-command-group>
<hlm-command-separator />
<hlm-command-group>
<hlm-command-group-label>Settings</hlm-command-group-label>
<button hlm-command-item value="profile" (selected)="commandSelected('profile')">
<ng-icon name="lucideUser" />
Profile
<hlm-command-shortcut>⌘P</hlm-command-shortcut>
</button>
<button hlm-command-item value="billing" (selected)="commandSelected('billing')">
<ng-icon name="lucideLayers" />
Billing
<hlm-command-shortcut>⌘B</hlm-command-shortcut>
</button>
<button hlm-command-item value="settings" (selected)="commandSelected('settings')">
<ng-icon name="lucideCog" />
Settings
<hlm-command-shortcut>⌘S</hlm-command-shortcut>
</button>
</hlm-command-group>
</hlm-command-list>
</hlm-command>
</hlm-command-dialog>
`,
})
export class CommandDialog {
public readonly command = signal('');
public readonly state = signal<'closed' | 'open'>('closed');
onKeyDown(event: KeyboardEvent) {
if ((event.metaKey || event.ctrlKey) && (event.key === 'j' || event.key === 'J')) {
this.state.set('open');
}
}
stateChanged(state: 'open' | 'closed') {
this.state.set(state);
}
commandSelected(selected: string) {
this.state.set('closed');
this.command.set(selected);
}
}Combobox
You can use the Command component as a combobox. Otherwise use the Combobox component for more advanced use cases.
import { Component, signal } from '@angular/core';
import { provideIcons } from '@ng-icons/core';
import { lucideCheck, lucideChevronsUpDown, lucideSearch } from '@ng-icons/lucide';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCommandImports } from '@spartan-ng/helm/command';
import { HlmIconImports } from '@spartan-ng/helm/icon';
import { HlmPopoverImports } from '@spartan-ng/helm/popover';
type Framework = { label: string; value: string };
@Component({
selector: 'spartan-command-combobox-preview',
imports: [HlmCommandImports, HlmIconImports, HlmButtonImports, HlmPopoverImports],
providers: [provideIcons({ lucideChevronsUpDown, lucideSearch, lucideCheck })],
template: `
<hlm-popover [state]="state()" (stateChanged)="stateChanged($event)" sideOffset="5">
<button
class="w-[200px] justify-between"
id="edit-profile"
hlmPopoverTrigger
(click)="state.set('open')"
hlmBtn
variant="outline"
>
{{ currentFramework() ? currentFramework()?.label : 'Select framework...' }}
<ng-icon hlm size="sm" name="lucideChevronsUpDown" class="opacity-50" />
</button>
<hlm-command *hlmPopoverPortal="let ctx" hlmPopoverContent class="w-[200px] p-0">
<hlm-command-input placeholder="Search framework..." />
<div *hlmCommandEmptyState hlmCommandEmpty>No results found.</div>
<hlm-command-list>
<hlm-command-group>
@for (framework of frameworks; track framework) {
<button hlm-command-item [value]="framework.value" (selected)="commandSelected(framework)">
<span>{{ framework.label }}</span>
<ng-icon
hlm
class="ml-auto"
[class.opacity-0]="currentFramework()?.value !== framework.value"
name="lucideCheck"
hlmCommandIcon
/>
</button>
}
</hlm-command-group>
</hlm-command-list>
</hlm-command>
</hlm-popover>
`,
})
export class CommandComboboxPreview {
public frameworks = [
{
label: 'AnalogJs',
value: 'analogjs',
},
{
label: 'Angular',
value: 'angular',
},
{
label: 'Vue',
value: 'vue',
},
{
label: 'Nuxt',
value: 'nuxt',
},
{
label: 'React',
value: 'react',
},
{
label: 'NextJs',
value: 'nextjs',
},
];
public readonly currentFramework = signal<Framework | undefined>(undefined);
public readonly state = signal<'closed' | 'open'>('closed');
stateChanged(state: 'open' | 'closed') {
this.state.set(state);
}
commandSelected(framework: Framework) {
this.state.set('closed');
if (this.currentFramework()?.value === framework.value) {
this.currentFramework.set(undefined);
} else {
this.currentFramework.set(framework);
}
}
}Brain API
BrnCommandEmpty
Selector: [brnCommandEmpty]
BrnCommandGroup
Selector: [brnCommandGroup]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-command-group-${++BrnCommandGroup._id}` | The id of the command list |
BrnCommandInput
Selector: input[brnCommandInput]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | this._initialId | The id of the command input |
BrnCommandItem
Selector: button[brnCommandItem]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-command-item-${++BrnCommandItem._id}` | A unique id for the item |
| value* (required) | string | - | The value this item represents. |
| disabled | boolean | false | Whether the item is disabled. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| selected | void | - | Emits when the item is selected. |
BrnCommandList
Selector: [brnCommandList]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-command-list-${++BrnCommandList._id}` | The id of the command list |
BrnCommandSeparator
Selector: [brnCommandSeparator]
BrnCommand
Selector: [brnCommand]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-command-${++BrnCommand._id}` | The id of the command |
| filter | CommandFilter | this._config.filter | A custom filter function to use when searching. |
| disabled | boolean | false | Whether the command is disabled |
| search | string | - | The current search query. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChange | string | - | when the selection has changed |
| searchChange | string | - | The current search query. |
Helm API
HlmCommandDialog
Selector: hlm-command-dialog
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Command Palette | - |
| description | string | Search for a command to run... | - |
| state | BrnDialogState | closed | - |
| showCloseButton | boolean | false | - |
| dialogContentClass | ClassValue | - | - |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| stateChange | BrnDialogState | - | - |
HlmCommandEmptyState
Selector: [hlmCommandEmptyState]
HlmCommandEmpty
Selector: [hlmCommandEmpty]
HlmCommandGroupLabel
Selector: [hlmCommandGroupLabel],hlm-command-group-label
HlmCommandGroup
Selector: [hlmCommandGroup],hlm-command-group
HlmCommandInput
Selector: hlm-command-input
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | undefined | - | - |
| placeholder | string | - | - |
HlmCommandItem
Selector: button[hlmCommandItem],button[hlm-command-item]
HlmCommandList
Selector: [hlmCommandList],hlm-command-list
HlmCommandSeparator
Selector: [hlmCommandSeparator],hlm-command-separator
HlmCommandShortcut
Selector: [hlmCommandShortcut],hlm-command-shortcut
HlmCommand
Selector: [hlmCommand],hlm-command
On This Page