BrowseCommand

Overlays

Glass Command

A quick-search palette that ranks commands as you type, inline or in a dialog.

Preview

Command menu

New file ⌘N Open recent ⌘O Copy link
Preferences ⌘, Switch theme

Installation

Install the package once, then import the parts you use into a standalone component.

Install

npm install ngx-vitreo @angular/cdk @floating-ui/dom
Import

import { GlassCommand, GlassCommandDialog, GlassCommandInput, GlassCommandList / GlassCommandEmpty, GlassCommandGroup, GlassCommandItem, GlassCommandSeparator / GlassCommandShortcut } from 'ngx-vitreo';

@Component({
  imports: [GlassCommand, GlassCommandDialog, GlassCommandInput, GlassCommandList / GlassCommandEmpty, GlassCommandGroup, GlassCommandItem, GlassCommandSeparator / GlassCommandShortcut],
  // ...
})

Usage

Usage

<glass-command-dialog [(open)]="open">
  <glass-command label="Commands">
    <glass-command-input placeholder="Type a command or search…" />
    <glass-command-list>
      <glass-command-empty>No results found.</glass-command-empty>
      <glass-command-group heading="Suggestions">
        <glass-command-item (select)="run($event)">
          New file
          <glass-command-shortcut>
            <span glassKbdGroup><kbd glassKbd>⌘</kbd><kbd glassKbd>N</kbd></span>
          </glass-command-shortcut>
        </glass-command-item>
      </glass-command-group>
      <glass-command-separator />
      <glass-command-group heading="Settings">
        <glass-command-item>Preferences</glass-command-item>
      </glass-command-group>
    </glass-command-list>
  </glass-command>
</glass-command-dialog>

API reference

GlassCommand

<glass-command>

InputTypeDefaultDescription
labelstringNoneAccessible name of the list. Not shown.
valuestring (model) first match The highlighted item's value, with [(value)].
shouldFilterbooleantrueSet to false to filter the items yourself.
filter(value: string, search: string, keywords?: string[]) => number cmdk's fuzzy score Scores each item from 0 (hidden) to 1 (best match).
loopbooleanfalseWraps the arrow keys from the last item to the first.

GlassCommandDialog

<glass-command-dialog>

InputTypeDefaultDescription
openboolean (model)falseControlled open state, with [(open)].
titlestring'Command menu'Accessible name of the dialog. Not shown.
classstringNoneClasses for the glass panel.

GlassCommandInput

<glass-command-input>

InputTypeDefaultDescription
valuestring (model)NoneControlled search text, with [(value)].
placeholderstringNoneShown while the field is empty.

GlassCommandList / GlassCommandEmpty

<glass-command-list>, <glass-command-empty>

InputTypeDefaultDescription
——NoneThe scrolling results, whose height follows them up to 22rem or 60% of the viewport, and what shows when nothing matches.

GlassCommandGroup

<glass-command-group>

InputTypeDefaultDescription
headingstringNoneA label over the group. The group hides while none of its items match.

GlassCommandItem

<glass-command-item>

InputTypeDefaultDescription
(select)stringNoneRuns on click or Enter, with the item's value.
valuestring its text What the search matches and the highlight reports.
keywordsstring[][]More words the search matches.
disabledbooleanfalseDims the item and skips it with the arrow keys.

GlassCommandSeparator / GlassCommandShortcut

<glass-command-separator>, <glass-command-shortcut>

InputTypeDefaultDescription
alwaysRenderbooleanfalseKeeps the separator while a search is typed. The shortcut pushes its keys to the end of the item.