Command
adn-ui/commandFreeComponent
Fast, composable command menu palette for searching and executing actions.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/command.jsonSource
1"use client";23import "./command.css";4import { Dialog as BaseDialog } from "@base-ui/react/dialog";5import React, { useState } from "react";6import { cn } from "tailwind-variants";78import { CommandContext, useCommandContext } from "./command.context";9import { commandVariants, type CommandVariants } from "./command.variants";1011export type CommandRootProps = CommandVariants &12 React.HTMLAttributes<HTMLDivElement> & {13 value?: string;14 onValueChange?: (value: string) => void;15 };1617export const CommandRoot = ({18 children,19 className,20 size,21 value,22 onValueChange,23 ...props24}: CommandRootProps) => {25 const [internalSearch, setInternalSearch] = useState("");26 const search = value !== undefined ? value : internalSearch;27 const setSearch = onValueChange ?? setInternalSearch;2829 const slots = commandVariants({ size });3031 return (32 <CommandContext.Provider value={{ slots, search, setSearch }}>33 <div className={cn(slots.root(), className)} {...props}>34 {children}35 </div>36 </CommandContext.Provider>37 );38};3940export type CommandDialogProps = React.ComponentProps<typeof BaseDialog.Root> & CommandRootProps;4142export const CommandDialog = ({43 children,44 open,45 onOpenChange,46 defaultOpen,47 className,48 size,49 ...props50}: CommandDialogProps) => {51 const slots = commandVariants({ size });5253 return (54 <BaseDialog.Root open={open} onOpenChange={onOpenChange} defaultOpen={defaultOpen}>55 <BaseDialog.Portal>56 <BaseDialog.Backdrop className={slots.dialogBackdrop()} />57 <BaseDialog.Popup className={cn(slots.dialogPopup(), className)}>58 <CommandRoot size={size} {...props}>59 {children}60 </CommandRoot>61 </BaseDialog.Popup>62 </BaseDialog.Portal>63 </BaseDialog.Root>64 );65};6667export type CommandInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "onChange"> & {68 value?: string;69 onValueChange?: (value: string) => void;70};7172export const CommandInput = ({ className, value, onValueChange, ...props }: CommandInputProps) => {73 const { slots, search, setSearch } = useCommandContext();7475 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {76 setSearch(e.target.value);77 onValueChange?.(e.target.value);78 };7980 return (81 <div className={slots.inputWrapper()}>82 <svg83 className="mr-2.5 h-4 w-4 shrink-0 text-muted-foreground"84 fill="none"85 stroke="currentColor"86 strokeWidth="2"87// … truncated
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Aspect Ratioaspect-ratio | adn-ui | Components | Free | 1 dep · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files |
