Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Add child item

Terry Suttonab1653835f40
diff --git a/packages/ui/src/components/Command/ChildItem.tsx b/packages/ui/src/components/Command/ChildItem.tsx
new file mode 100644
index 00000000000..58627565bd7
--- /dev/null
+++ b/packages/ui/src/components/Command/ChildItem.tsx
@@ -0,0 +1,11 @@
+import { useCommandState } from 'cmdk-supabase'
+import { CommandItem } from './Command.utils'
+import React from 'react'
+
+export default function ChildItem({ children, isSubItem, ...props }: any) {
+ const search = useCommandState((state) => state.search)
+ // if search is empty & items is marked as a subItem, don't show it
+ // ie: only show these items in search results, not top level
+ if (!search && isSubItem) return null
+ return <CommandItem {...props}>{children}</CommandItem>
+}