In this episode, we focus on making our custom Toast component actually look nice and behave smoothly. Up to this point, the toast was functional, but now it's time to dive into styling and animating it.
First, we revamp the toast's markup and use Tailwind CSS to position it at the top center of the page. We add some background color, text color, margins, padding, and even bump up the z-index to make sure it floats above everything else. The result is a visually appealing notification that feels right at home in any modern UI.
Once styled, we tackle transitions by using Headless UI's TransitionRoot and TransitionChild components. We set up fade and slide effects for both entering and leaving, so the toast smoothly drops down when it appears and glides back up while fading out when it disappears. You’ll see how the transition props work in practice, and how easy Headless UI makes the whole process.
By the end of this video, our toast looks great and behaves elegantly, ready to be reused anywhere in our app. We even tweak the display duration for a better user experience. From here, whether it’s a success message, error, or any quick notification, our toast component is good to go!