Transition property selection lets you choose which CSS properties change smoothly when something on the page updates. This makes changes look nicer and less sudden.
Transition property selection in Tailwind
transition-[property]
Replace [property] with the CSS property name you want to animate, like background-color or opacity.
Tailwind uses kebab-case (dashes) for CSS properties, for example, transition-[background-color] for background-color.
transition-[background-color]
transition-opacity
transition-colors
transition-transform
This example shows a blue button that changes its background color smoothly when you hover over it. The transition-[background-color] class tells Tailwind to animate only the background color. The duration-500 sets the animation to last half a second. Accessibility is improved with aria-label and focus styles.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Transition Property Selection Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex items-center justify-center min-h-screen bg-gray-100"> <button class="bg-blue-600 text-white px-6 py-3 rounded transition-[background-color] duration-500 hover:bg-blue-400 focus:outline-none focus:ring-4 focus:ring-blue-300" aria-label="Smooth background color transition button"> Hover me </button> </body> </html>
You can combine transition-[property] with duration-[time] and ease-[type] classes to control speed and easing.
Use semantic HTML and ARIA labels to keep interactive elements accessible.
Test transitions on different devices to ensure smooth performance.
Transition property selection controls which CSS properties animate smoothly.
Use Tailwind classes like transition-[background-color] or transition-opacity to pick properties.
Combine with duration and easing classes for better control and user experience.