Ring and outline colors help highlight elements on a webpage. They make it easier to see which part is focused or selected.
Ring and outline colors in Tailwind
ring-{width} ring-{color} ring-offset-{width} ring-offset-{color} outline-{width} outline-{color}ring-{width} sets the thickness of the ring around an element.
ring-{color} sets the color of the ring using Tailwind color names.
<button class="ring-2 ring-blue-500">Click me</button><input class="outline-4 outline-red-500" type="text" placeholder="Type here">
<div class="ring-4 ring-green-400 ring-offset-2 ring-offset-white">Box</div>This page shows three elements with different ring and outline colors. The button has a purple ring with a light gray offset. The input has a thick pink outline. The box has a thick yellow ring with a black offset behind it.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Ring and Outline Colors Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="flex flex-col items-center gap-6 p-6"> <button class="ring-4 ring-purple-600 ring-offset-2 ring-offset-gray-100 px-4 py-2 rounded"> Purple Ring Button </button> <input class="outline-4 outline-pink-500 px-3 py-2 rounded" type="text" placeholder="Pink outline input" /> <div class="ring-8 ring-yellow-400 ring-offset-4 ring-offset-black text-black px-6 py-4 rounded"> Yellow ring with black offset </div> </body> </html>
Use ring-offset classes to add space between the element and the ring color.
Outline colors and widths can be combined but may behave differently across browsers.
Rings do not affect layout size, so they won't push other elements away.
Ring colors add a colored glow around elements without changing layout.
Outline colors create a border-like effect that can be styled with thickness and color.
Use these styles to improve focus visibility and add visual emphasis.