Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default value prop #123

Merged
merged 5 commits into from
May 3, 2023
Merged

feat: add default value prop #123

merged 5 commits into from
May 3, 2023

Conversation

revogabe
Copy link
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
Copy link

vercel bot commented Apr 18, 2023

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
Contributor Author

Done! 🥳

@pacocoursey pacocoursey merged commit bbcc8cf into pacocoursey:main May 3, 2023
1 check passed
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