nuxt / ui

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

Can't remove close button on UNotifications individually #2163

Closed hdwebpros closed 2 months ago

hdwebpros commented 2 months ago

Environment


Version

v2.18.4

Reproduction

https://stackblitz.com/edit/nuxt-ui-aoidlu?file=app.vue

Description

As of right now, there is no feature to allow disabling notifications on the notifications itself. https://github.com/nuxt/ui/blob/dev/src/runtime/components/overlays/Notification.vue#L90-L93 That prop default is always going to fall back to the global closeButton UI config if you either omit it or pass any falsy looking value (null, false, undefined, etc.) through. And the config itself doesn’t have a way to just say “no render”.

Additional context

No response

Logs

No response

benjamincanac commented 2 months ago

Have you tried passing closeButton: null to useToast.add()?

hdwebpros commented 2 months ago

@benjamincanac I'm not using this in the useToast way. Just the straight UNotification way.

benjamincanac commented 2 months ago

Then, <UNotification :close-button="null" />?

hdwebpros commented 2 months ago

Wow, that did work! According to https://ui.nuxt.com/components/notification#close I didn't see that we could null it to disable. Perhaps that should be added to the docs. I'm glad that's fixed!

mubaidr commented 2 weeks ago

How to disable close-button by default using app.config.ts? because it does not support ui and neither null value.