diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index 3131c7b..f8321e8 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -94,6 +94,10 @@ type CommandProps = Children & * By default, uses the `command-score` library. */ filter?: CommandFilter + /** + * Optional default search value when it is initially rendered. + */ + defaultSearch?: string /** * Optional default item value when it is initially rendered. */ @@ -169,7 +173,7 @@ const GroupContext = React.createContext(undefined) const Command = React.forwardRef((props, forwardedRef) => { const state = useLazyRef(() => ({ /** Value of the search query. */ - search: '', + search: props.defaultSearch ?? '', /** Currently selected item value. */ value: props.value ?? props.defaultValue ?? '', /** Currently selected item id. */