Arbitrary values let you use custom sizes or colors not in Tailwind's default list. This helps you make your design exactly how you want.
Why arbitrary values exist in Tailwind
class="property-[value]"Use square brackets [ ] to wrap your custom value.
Make sure to write the value exactly as CSS expects, including units like rem, px, %, etc.
class="bg-[#1a2b3c]"class="mt-[3.5rem]"class="rounded-[12px]"class="text-[18px]"This example shows a button with a custom background color, padding, and rounded corners using arbitrary values. When you hover, the background changes to another custom color.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Arbitrary Values 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-[#ff6347] text-white px-[2.5rem] py-[1rem] rounded-[1.25rem] hover:bg-[#e5533d] transition"> Custom Button </button> </body> </html>
Arbitrary values give you freedom but use them wisely to keep your design consistent.
Always include units like rem or px when needed, or the style might not work.
Check your browser's developer tools to see the applied styles and debug if needed.
Arbitrary values let you use any CSS value inside Tailwind classes.
They help you customize designs beyond Tailwind's default options.
Use square brackets and include proper units for your custom values.