question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it easier to work with Tailwind

See original GitHub issue

I’m trying to customize my toasts with Tailwind, but I’m currently struggling with the default styles. I’m trying to override the styles with Tailwind but I can’t remove the default classes:

export const Toast: React.FunctionComponent<ToastProps> = ({
  position = 'bottom-center',
  toastOptions = {
    className: 'text-xs font-semibold rounded-lg p-2',
    success: {
      icon: null,
      className: 'text-xs font-semibold rounded-lg p-2 bg-green-300 text-green-900',
    },
    error: {
      icon: null,
      className: 'text-xs font-semibold rounded-lg p-2 bg-red-300 text-red-900',
    },
  },
  ...props
}: ToastProps) => {
  return (
    <Toaster position={position} toastOptions={toastOptions} {...props}>
      {(t) => (
        <ToastBar toast={t} position={position}>
          {({ message }) => (
            <>
              {message}
             
            </>
          )}
        </ToastBar>
      )}
    </Toaster>
  );
};

But they are overrided with those styles https://github.com/timolins/react-hot-toast/blob/d1456c4e4fdc8210f24b08334a2a464efa815eb0/src/components/toast-bar.tsx#L21-L33 and I can’t even override those ones (remove margin) https://github.com/timolins/react-hot-toast/blob/d1456c4e4fdc8210f24b08334a2a464efa815eb0/src/components/toast-bar.tsx#L35-L41 Please think about removing those default styles so we can easily theme them by adding classes and styles or by adding an extra div.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
timolinscommented, Jun 9, 2022

@chrisrobbins Have a look at this example, which uses the Custom Renderer API, TailwindCSS & HeadlessUI for easy animations: https://codesandbox.io/s/react-hot-toast-tailwindcss-headless-ui-qvjri?file=/src/App.js

0reactions
DavidRouyercommented, Jun 28, 2022

I made my own <Toaster /> component so I could style anything the way I wanted

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Tailwind CSS to Rapidly Develop Snazzy Websites
Tailwind CSS is a powerful CSS framework that can cut down on your development time so you can focus on what's important.
Read more >
10 Tailwind CSS tips to boost your productivity - LogRocket Blog
I like Tailwind for two reasons. First, it makes building responsive interfaces so much easier. When you master all the utility classes, ...
Read more >
How Tailwind Can Help You Code Faster - DEV Community ‍ ‍
Tailwind makes your life easier as a developer, whether you're a pro at CSS or not. Writing CSS more easily means less frustration...
Read more >
How to use Tailwind CSS the clean way | by Lewin Probst
Why do you tend to write messy HTML code when using Tailwind CSS? ... As stated earlier, Tailwind is a utility-first framework that...
Read more >
Tailwind CSS: What It Is, Why Use It & Examples - HubSpot Blog
Tailwind CSS is a utility-first CSS framework designed to enable users to create applications faster and easier. You can use utility classes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found