UNPKG

@neynar/ui

Version:

React UI component library built on shadcn/ui and Tailwind CSS

63 lines (53 loc) 1.6 kB
# CommandEmpty **Type**: component CommandEmpty - Empty state message for command menu Displays when no command items match the current search query. Can contain custom content beyond simple text messages. Automatically shows/hides based on filtered results and announces changes to screen readers. Supports dynamic content using the `useCommandState` hook to access current search term and create contextual empty messages. ## JSX Usage ```jsx import { CommandEmpty } from '@neynar/ui'; <CommandEmpty className="value" > {/* Your content here */} </CommandEmpty> ``` ## Component Props ### className - **Type**: `string` - **Required**: No - **Description**: Additional CSS classes ### children - **Type**: `React.ReactNode` - **Required**: No - **Description**: No description available ## Examples ### Example 1 ```tsx <CommandList> <CommandEmpty>No commands found.</CommandEmpty> </CommandList> ``` ### Example 2 ```tsx // Custom empty state with icon and helpful text <CommandEmpty> <div className="py-6 text-center"> <SearchIcon className="mx-auto h-10 w-10 text-muted-foreground/50" /> <h3 className="mt-2 text-sm font-medium">No results found</h3> <p className="mt-1 text-sm text-muted-foreground"> Try adjusting your search terms. </p> </div> </CommandEmpty> ``` ### Example 3 ```tsx // Dynamic empty message with search term function DynamicEmpty() { const search = useCommandState((state) => state.search); return ( <CommandEmpty> {search ? `No results found for "${search}".` : 'Start typing to search...'} </CommandEmpty> ); } ```