diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index fb7ba0b..7bf45fb 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -74,6 +74,10 @@ type CommandProps = Children & * By default, uses the `command-score` library. */ filter?: (value: string, search: string) => number + /** + * Optional default item value when it is initially rendered. + */ + defaultValue?: string /** * Optional controlled state of the selected command menu item. */ @@ -137,7 +141,7 @@ const Command = React.forwardRef((props, forwarded /** Value of the search query. */ search: '', /** Currently selected item value. */ - value: props.value ?? '', + value: props.value ?? props.defaultValue?.toLowerCase() ?? '', filtered: { /** The count of all visible items. */ count: 0,