Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ustyled prop and close button #433

Open
rlesniak opened this issue Jun 5, 2024 · 2 comments
Open

Ustyled prop and close button #433

rlesniak opened this issue Jun 5, 2024 · 2 comments

Comments

@rlesniak
Copy link

rlesniak commented Jun 5, 2024

Despite setting closeButton: '-right-1 top-2 left-auto text-teal-500 border-none hover:bg-teal-500'

<SonnerToaster
  toastOptions={{
    unstyled: true,
    duration: 100_000,
    closeButton: true,
    classNames: {
      toast: 'group toast rounded-lg flex items-center gap-5 px-4 py-2 pr-6',
      content: ' flex items-center',
      closeButton:
        '-right-1 top-2 left-auto text-teal-500 border-none hover:bg-teal-500',
      success: 'bg-teal-100 border border-teal-200 text-teal-800 text-lg',
    },
  }}
/>

I still get hover style for close button. I dont want this

image

@Wordllban
Copy link

I found the solution, you need to use ! which makes tailwindcss utility classes to use css !important like:

closeButton:
        '-right-1 top-2 left-auto text-teal-500 border-none !hover:bg-teal-500'

But this won't work with hover or other pseudo-class

I guess selector from this line just have more weight (you can learn about weights there)
https://github.com/emilkowalski/sonner/blob/main/src/styles.css#L248

So I ended up with override of this selector in project global.css file:

:where([data-sonner-toast]):hover :where([data-close-button]):hover {
    background: none !important;
    border-color: blue !important;
}

@cleytoncarvalho
Copy link

I encountered the same issue. I believe it makes more sense for the closeButton to have no styles when {unstyled: true} is applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants