nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
22.01k stars 1.54k forks source link

[Feature Request] Autocomplete render trailing custom element functionality #2925

Open CelloAdrian opened 6 months ago

CelloAdrian commented 6 months ago

Is your feature request related to a problem? Please describe.

When dynamically populating autocomplete from an array, we don't have an option to render a custom element to the Autocomplete component, in this case for example a "Create New" button

Describe the solution you'd like

It would be nice to be able to render a custom element in the Autocomplete component when we specify the prop

Describe alternatives you've considered

Material UI has this functionality : https://mui.com/material-ui/react-autocomplete/#FreeSoloCreateOption.js

Screenshots or Videos

image image

linear[bot] commented 6 months ago

ENG-774 [Feature Request] Autocomplete create item functionality

ryo-manba commented 6 months ago

Thanks for the issue! As a workaround, you could potentially add a custom item like Add "{inputValue}" when the list of filtered items becomes empty using the onInputChange event. Additionally, you could remove any prefix from the message in the onSelectionChange event based on the key. If you try this out, please let us know how it goes!