Skip to content

Link not working inside AutoCompleteItem #2086

Closed Answered by srivatsa17
srivatsa17 asked this question in Help
Discussion options

You must be logged in to vote

You can do something like this.

import { Autocomplete, AutocompleteItem, Link } from "@nextui-org/react";

<AutoComplete
 ...
>
  {(category) => (
    <AutocompleteItem
      key={category.name ?? ""}
      value={category.name}
      className="capitalize"
      onSelectionChange={() => {
         router.push('link here')
      }}
    >
        {category.name}
    </AutocompleteItem>
  )}
</AutoComplete>

Thanks for the response! I tried this and its working now. I don't know if its the right approach though

{(category) => (
    <AutocompleteItem
        ...
        as={Link}
        href=`my link`
    >
        {category.name}
    </AutocompleteItem>
)}

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by srivatsa17
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@timsntech
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants