Application
Command Menu
cmdk command palette with fuzzy search, groups, and shortcuts; also as a ⌘K dialog.
MotionCommandDialog uses the Dialog spring; list filtering by cmdk
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
} from "kineto/command";Preview
No results found.
Search members
Billing ⌘B
Preferences ⌘,
tsx
"use client";
import * as React from "react";
import { Command as CommandPrimitive } from "cmdk";
import { Search } from "lucide-react";
import { cn } from "@/lib/cn";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
>(({ className, ...props }, ref) => (
<CommandPrimitive
ref={ref}
className={cn(
"flex size-full flex-col overflow-hidden rounded-xl bg-popover text-popover-foreground",
className
)}
{...props}
/>
));
Command.displayName = "Command";
export interface CommandDialogProps {
open?: boolean;
onOpenChange?: (open: boolean) => void;
children: React.ReactNode;
title?: string;
}
function CommandDialog({ open, onOpenChange, children, title = "Command menu" }: CommandDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-xl overflow-hidden p-0">
<DialogTitle className="sr-only">{title}</DialogTitle>
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground">
{children}
</Command>
</DialogContent>
</Dialog>
);
}
const CommandInput = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Input>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className="flex items-center gap-2 border-b border-border px-4">
<Search className="size-4 shrink-0 text-muted-foreground" />
<CommandPrimitive.Input
ref={ref}
className={cn(
"flex h-12 w-full bg-transparent py-3 text-sm text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
/>
</div>
));
CommandInput.displayName = "CommandInput";
const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
>(({ className, ...props }, ref) => (
<CommandPrimitive.List
ref={ref}
className={cn("max-h-80 overflow-y-auto overflow-x-hidden p-1.5", className)}
{...props}
/>
));
CommandList.displayName = "CommandList";
const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Empty
ref={ref}
className={cn("py-8 text-center text-sm text-muted-foreground", className)}
{...props}
/>
));
CommandEmpty.displayName = "CommandEmpty";
const CommandGroup = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Group>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Group ref={ref} className={cn("text-foreground", className)} {...props} />
));
CommandGroup.displayName = "CommandGroup";
const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-pointer select-none items-center gap-2.5 rounded-lg px-2.5 py-2 text-sm text-foreground outline-none transition-colors data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground",
className
)}
{...props}
/>
));
CommandItem.displayName = "CommandItem";
const CommandSeparator = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Separator
ref={ref}
className={cn("-mx-1.5 my-1.5 h-px bg-border", className)}
{...props}
/>
));
CommandSeparator.displayName = "CommandSeparator";
const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => (
<span
className={cn("ml-auto font-mono text-xs tracking-widest text-muted-foreground", className)}
{...props}
/>
);
CommandShortcut.displayName = "CommandShortcut";
export {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandSeparator,
CommandShortcut,
};src/components/ui/command.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| Command* | components | — | Input, List, Group, Item, Separator, Shortcut. |
| CommandDialog | { open; onOpenChange } | — | Wrap in the animated dialog for ⌘K. |