Create new item via combobox #3983
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Hey there! For implementing a "create" variant within a combobox, you can indeed customize the options in a combobox to include a "create" option. When you're at the build stage, here's how you can achieve this interaction:
This approach allows users to select from existing options or create a new one. The combobox remains an input field where users can type directly. After typing a new value, users can still open the dropdown to switch to an existing list item if they choose to. Here's a snippet from the documentation that outlines this process: // Example of adding a "create" option at the end of the items array
const items = [...yourExistingItems, 'Create new item'];
// Example of using the option template to render the "create" option
<OptionTemplate>
{item === 'Create new item' ? (
<CustomCreateOption />
) : (
<DefaultOption item={item} />
)}
</OptionTemplate> For more detailed guidance and to adapt this to your specific needs, you might want to check the Combobox documentation and the update regarding the combobox component that allows for customizable options, including a "create" variant. I hope this helps! If you have any more questions or need further assistance, feel free to ask. I also did a search, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
Hi @charleneyjh1 Sure here is a clarification of how this interaction works:
Also you can check this Code Sandbox demo created by our engineers. This was a time-boxed task so it gets the functionality most of the way there: It doesn't close/clear the Combobox on select, and you'll have to add the matching hover/focus state. We're working on ways to have a better documentation for this. Please let us know if you need help with anything else. |
Beta Was this translation helpful? Give feedback.
Hi @charleneyjh1 Sure here is a clarification of how this interaction works:
Also you can check this Code Sandbox demo created by our engineers. This was a time-boxed task so it gets the functionality most of the way there: It doesn't close/clear the Combobox on select, and you'll have to add the matching hover/focus state.
We're working on ways to have a better d…