Comando

Una lista de opciones o acciones con búsqueda, integrada o como paleta.

Lista con búsqueda

Una lista con búsqueda: escribe para filtrar los grupos, usa las flechas para moverte e Intro para elegir; el valor elegido aparece marcado.

<script setup>
import { ref } from 'vue';
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '@aisgroup/design/ui/command';
const value = ref('m-inspection-02');
</script>

<template>
  <Command v-model="value" class="max-w-sm border">
    <CommandInput placeholder="Search models" />
    <CommandList>
      <CommandEmpty>No model matches.</CommandEmpty>
      <CommandGroup heading="PCB inspection">
        <CommandItem value="m-inspection-01">m-inspection-01</CommandItem>
        <CommandItem value="m-inspection-02">m-inspection-02</CommandItem>
      </CommandGroup>
      <CommandSeparator />
      <CommandGroup heading="Tortilla line">
        <CommandItem value="m-food-01">m-food-01</CommandItem>
        <CommandItem value="m-food-02">m-food-02</CommandItem>
      </CommandGroup>
    </CommandList>
  </Command>
</template>

Paleta

Una paleta de comandos en un diálogo, que se abre con su botón o con Ctrl K (Cmd K en un Mac): busca y ejecuta con Intro.

<script setup>
import { ref } from 'vue';
import { useEventListener } from '@vueuse/core';
import { DatabaseIcon, PlusIcon, SearchIcon, SettingsIcon, BoxIcon } from '@lucide/vue';
import { Button } from '@aisgroup/design/ui/button';
import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '@aisgroup/design/ui/command';
import { Kbd } from '@aisgroup/design/ui/kbd';
const open = ref(false);
useEventListener('keydown', (e) => {
  if (e.key.toLowerCase() === 'k' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); open.value = !open.value; }
});
</script>

<template>
  <Button variant="outline" class="w-64 justify-start text-muted-foreground" @click="open = true">
    <SearchIcon data-icon="inline-start" />Search<Kbd class="ml-auto">Ctrl K</Kbd>
  </Button>
  <CommandDialog v-model:open="open">
    <CommandInput placeholder="Type a command or search" />
    <CommandList>
      <CommandEmpty>No results.</CommandEmpty>
      <CommandGroup heading="Create">
        <CommandItem value="new-dataset" @select="open = false"><PlusIcon />New dataset</CommandItem>
        <CommandItem value="new-model" @select="open = false"><PlusIcon />New model</CommandItem>
      </CommandGroup>
      <CommandSeparator />
      <CommandGroup heading="Go to">
        <CommandItem value="datasets" @select="open = false"><DatabaseIcon />Datasets</CommandItem>
        <CommandItem value="models" @select="open = false"><BoxIcon />Models</CommandItem>
        <CommandItem value="settings" @select="open = false"><SettingsIcon />Settings</CommandItem>
      </CommandGroup>
    </CommandList>
  </CommandDialog>
</template>

Escribe para buscar en la guía.