nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
4.07k stars 525 forks source link

How do I clear a selected item in the selectMenu component? #1275

Closed wallysonn closed 9 months ago

wallysonn commented 9 months ago

Description

Would it be possible to add an "x" to the component to clear it?

benjamincanac commented 9 months ago

Have you tried using the #trailing slot like the Select? https://ui.nuxt.com/forms/select#trailing

benjamincanac commented 9 months ago

Duplicate #1057

wallysonn commented 9 months ago

Have you tried using the #trailing slot like the Select? https://ui.nuxt.com/forms/select#trailing

Thank you for taking the time to answer my question. In this case I am using the SelectMenu component and not Select. SelectMenu is better for my needs, as it is visually more beautiful and functional with the search field. His problem, I don't know how to get around it at all, is that after I select an item, I can't remove the selection.

benjamincanac commented 9 months ago

The SelectMenu inherits from the Select, you can use the #trailing slot there too.

By design, a select can't be unselected, this is the normal behaviour. You either use the #trailing slot, add another button on the side with the ButtonGroup component or make it multiple to be able to unselect values.

wallysonn commented 9 months ago

The SelectMenu inherits from the Select, you can use the #trailing slot there too.

By design, a select can't be unselected, this is the normal behaviour. You either use the #trailing slot, add another button on the side with the ButtonGroup component or make it multiple to be able to unselect values.

Forgive my lack of attention. I understood that it only worked in the Select component. I tested it here and it worked perfect. Thank you and have an amazing day.