Skip to content

feat: add default value prop#123

Merged
pacocoursey merged 5 commits into
dip:mainfrom
revogabe:main
May 3, 2023
Merged

feat: add default value prop#123
pacocoursey merged 5 commits into
dip:mainfrom
revogabe:main

Conversation

@revogabe

Copy link
Copy Markdown
Contributor

Closes #115

In this PR, I added the optional prop of default value, which, when passing the item's value to the default value, makes this item active. Otherwise, the function of activating the first item on the list continues.

BEFORE

const [value, setValue] = React.useState('apple')

return (
  <Command value={value} onValueChange={setValue}>
    <Command.Input />
    <Command.List>
      <Command.Item>Orange</Command.Item>
      <Command.Item>Apple</Command.Item>
    </Command.List>
  </Command>
)

NOW

return (
  <Command defaultValue="Apple">
    <Command.Input />
    <Command.List>
      <Command.Item>Orange</Command.Item>
      <Command.Item>Apple</Command.Item>
    </Command.List>
  </Command>
)

@vercel

vercel Bot commented Apr 18, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cmdk-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2023 1:20pm

@revogabe

Copy link
Copy Markdown
Contributor Author

Done! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add defaultValue prop to Command part

2 participants