Escaping Configuration Bloat with Tailwind CSS Arbitrary Values
Tailwind's arbitrary values let you apply one-off sizes, colors and grid layouts with [value] syntax, keeping tailwind.config.js clean for global design tokens while still generating optimized CSS.
09 Apr 2026, 18:09 UTC

Real projects hit a one-off styling request: a 13px margin for a legacy hero, a brand hex used only on a single landing page, or a three-column grid with 200px, 1fr, 100px. With Tailwind CSS the usual move is to extend tailwind.config.js. Doing that for single-use tokens turns the theme into a graveyard of disposable values and hides the real design system.
Arbitrary values give an escape hatch. With square bracket syntax [value] you can inject a specific measurement, color or layout directly in a class. Tailwind parses the bracket at build time and emits a unique utility, so the config stays clean for truly global tokens.
Why configuration bloat matters
In a standard workflow a non-theme color is added to the config:
module.exports = {
theme: {
extend: {
colors: {
'brand-gold': '#bbff64',
},
},
},
}If five different shades of gold are used once on one page, the config accumulates values that will never be reused. That makes audits harder and increases the chance of drift when the design system evolves. Arbitrary values keep those one-offs in markup where they belong.
How arbitrary values are generated
Tailwind treats [value] as a literal for almost any utility. The engine scans class names, extracts the bracketed content, and generates a CSS rule for that exact value during the build. Purge remains effective because only classes present in source files are emitted.
Examples of the form:
- margin-top-[13px]
- background-color-[#bbff64]
- grid-cols-[200px_1fr_100px]
Worked example: custom grid and one-off color
A layout that does not fit the default scale can be expressed without config changes:
<div class='grid grid-cols-[200px_1fr_100px] gap-4'>
<div class='bg-[#f3f4f6]'>Sidebar</div>
<div class='bg-white'>Main Content</div>
<div class='bg-[#bbff64]'>Ad Space</div>
</div>grid-cols-[200px_1fr_100px] defines three explicit tracks. bg-[#bbff64] applies a specific hex without adding it to the theme. The same pattern works for spacing, sizing and positioning, e.g. top-[117px].
Spaces, calc and syntax limits
Class names cannot contain spaces. Inside brackets use underscores to represent spaces. The compiler converts underscores back to spaces in the output CSS.
<div class='w-[calc(100%-2rem)]'>
Content
</div>This emits width: calc(100% - 2rem). Avoid spaces inside the brackets, otherwise the class name is parsed incorrectly.
Trade-off: speed vs consistency
Arbitrary values are an escape hatch, not a design token. Repeating top-[117px] across components hard-codes values with different syntax. The practical rule is: use arbitrary values for truly unique, one-off requirements. If a value appears more than twice or spans pages, promote it to tailwind.config.js so it can be updated globally.
Overuse also reduces discoverability. Team members cannot find a value by searching the theme, and visual consistency suffers when similar values are expressed as 117px, [117px] and 118px.
Verification
Check that the class is emitted and not purged. Apply top-[117px] to an element and inspect the element in browser dev tools. The computed rule should show top: 117px.
For build confidence, check the built CSS output for a selector matching the arbitrary class. If the class is used in source files, Tailwind includes it; if it is absent, purging removes it.
Keep the config for shared tokens, use arbitrary values for exceptions, and promote repeated exceptions back to the theme.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.