Discover how to break free from preset limits and style anything exactly how you want with Tailwind!
Why arbitrary values exist in Tailwind - The Real Reasons
Imagine you want a button with a very specific shade of blue that Tailwind doesn't have by default.
You try to pick the closest color from the preset list, but it never looks quite right.
Manually overriding styles with custom CSS means extra files, more code, and harder maintenance.
You lose the simplicity and speed that Tailwind promises.
Arbitrary values let you write exactly the style you want right inside your Tailwind class.
No extra CSS files, no guessing--just precise control with simple syntax.
class="bg-blue-500" style="background-color: #3a86ff;"
class="bg-[#3a86ff]"
You can customize designs freely while keeping Tailwind's fast, clean workflow.
A designer wants a card with a unique shadow color that isn't in Tailwind's palette. Using arbitrary values, you add shadow-[0_4px_6px_rgba(58,134,255,0.5)] directly in the class.
Manual CSS overrides slow you down and clutter your code.
Arbitrary values let you write exact styles inside Tailwind classes.
This keeps your code clean, fast, and easy to maintain.
Practice
Solution
Step 1: Understand Tailwind's default options
Tailwind provides many predefined classes but cannot cover every possible CSS value.Step 2: Purpose of arbitrary values
Arbitrary values let you write any CSS value inside square brackets to customize styles beyond defaults.Final Answer:
To allow using any custom CSS value beyond default Tailwind options -> Option AQuick Check:
Arbitrary values = custom CSS values [OK]
- Thinking arbitrary values limit styling
- Confusing arbitrary values with animations
- Believing arbitrary values replace JavaScript
Solution
Step 1: Recall Tailwind arbitrary value syntax
Arbitrary values use square brackets with the CSS value inside, e.g.,w-[450px].Step 2: Check each option
Onlyw-[450px]uses square brackets and includes units correctly.Final Answer:
w-[450px]-> Option BQuick Check:
Correct syntax = w-[450px] [OK]
- Omitting square brackets
- Missing units like px
- Using dash instead of brackets
<div class="w-[30rem] bg-blue-500 text-white p-4">Hello</div>
Solution
Step 1: Interpret the class
This sets the width to exactly 30rem, which is about 480 pixels (1rem ≈ 16px).w-[30rem]Step 2: Check other classes
bg-blue-500sets a blue background,text-whitesets white text, andp-4adds padding.Final Answer:
Width of 30rem (about 480px) with blue background -> Option CQuick Check:
Arbitrary width 30rem + blue bg = Width of 30rem (about 480px) with blue background [OK]
- Confusing rem with px
- Ignoring background color class
- Assuming default width
<div class="h-[100] bg-red-400">Error</div>
Solution
Step 1: Check the arbitrary value syntax
The height is set ash-[100]but lacks units like px or rem.Step 2: Understand CSS requirements
CSS requires units for length values unless it's zero; so100alone is invalid.Final Answer:
Missing units inside the arbitrary value brackets -> Option AQuick Check:
Units required inside brackets [OK]
- Forgetting units inside arbitrary values
- Thinking brackets are wrong syntax
- Assuming Tailwind classes are invalid
Solution
Step 1: Use square brackets for arbitrary values
Custom values must be inside square brackets with units, e.g.,rounded-[12px]andp-[1.25rem].Step 2: Check each option
Onlyrounded-[12px] p-[1.25rem]correctly uses brackets and includes units for both border radius and padding.Final Answer:
rounded-[12px] p-[1.25rem]-> Option DQuick Check:
Arbitrary values need brackets + units [OK]
- Omitting brackets
- Leaving out units
- Mixing syntax without brackets
Ready to prove it?
Pass the test and this pattern moves unknown
