I’m Kayla. I ship front-end stuff for a living. Last week, I hit a wall. I needed more Tailwind classes than my build was giving me. So I rebuilt Tailwind, and yes—made it spit out more classes on demand. Simple idea. Not always simple in practice.
If you want the blow-by-blow of that reconstruction, I wrote it up in detail in this post.
You know what? It was worth it.
My setup (quick and plain)
- MacBook Air M2
- Node 18
- Vite + React
- Tailwind CSS v3.4
- VS Code with Tailwind IntelliSense
If you ever need a quick way to prototype responsive menus outside of Tailwind, take a look at CSS Menu Tools—it’s a surprisingly handy companion.
I had a small dashboard. Charts, cards, tables. Nothing huge, but picky design. I needed odd spacing, new colors, and one weird grid.
Those same custom-value hacks came in handy the week I tinkered with Squarespace’s design panel—spoiler: you can inject far more CSS than the UI suggests, as I show over here.
The moment it broke
I added “p-13” for 13px padding. Nothing happened. Then I added “w-15%”. Still nothing. I forgot: Tailwind only builds what it sees. And it does not guess odd values.
So I switched to the “custom value” style. Like this:
- p-[13px]
- w-[15%]
- top-[3.25rem]
- grid-cols-[200px_1fr]
Boom. Tailwind rebuilt, and the styles appeared. It felt like magic, but it was just JIT doing its job.
When I really needed a rebuild
Sometimes the dev server didn’t catch a new file. Or I added classes in a string from an API. Those don’t show in the scan. So I had to rebuild and also make Tailwind “know” what to keep.
Here’s my tailwind.config.js that got me over the hump:
// tailwind.config.js
module.exports = {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
brand: {
DEFAULT: "#0ea5e9",
dark: "#0369a1",
light: "#7dd3fc",
},
},
spacing: {
13: "3.25rem", // tailwind doesn’t ship this one by default
},
},
},
plugins: [
require("@tailwindcss/forms"),
require("@tailwindcss/typography"),
],
safelist: [
"bg-brand",
"bg-brand-dark",
"text-brand",
{ pattern: /(bg|text|border)-(red|blue|green)-(100|500|700)/ },
],
};
Why the safelist? I had some styles coming from data. Like a status color. If Tailwind can’t see the class in the code, it won’t build it. Safelist tells it, “keep these anyway.” If you’re curious about how this evolves in v4, there’s a detailed answer on Stack Overflow.
Real classes I added (and used)
- Buttons
- "px-3 py-2 font-medium text-white bg-emerald-600 hover:bg-emerald-700 active:bg-emerald-800 focus:outline-none focus:ring-2 focus:ring-emerald-400"
- Odd spacing
- "p-[13px] mt-[7px] gap-[3px]"
- Semi see-through hover
- "hover:bg-lime-600/80"
- Custom grid
- "grid grid-cols-[200px_1fr] md:grid-cols-[260px_1fr]"
- Fancy width
- "w-[15%] md:w-[22%]"
- Aspect ratio for images
- "aspect-[4/3] object-cover"
- A CSS variable color (handy in themes)
- "bg-[–brand] text-white"
I also tossed some shared styles into a small component layer. It kept my JSX sane:
/* src/styles/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.btn-primary {
@apply inline-flex items-center gap-2 px-3 py-2 rounded-md
font-medium text-white bg-brand hover:bg-brand-dark
focus:outline-none focus:ring-2 focus:ring-brand;
}
.card {
@apply rounded-lg border border-gray-200 bg-white p-4 shadow-sm;
}
}
Now I can just write:
- className="btn-primary"
- className="card"
Cleaner. Faster. Less noise.
The commands that actually helped
- Dev with fast rebuilds:
- "npm run dev" with Vite was enough. Each save rebuilt in under a second for me.
- Full build:
- "npm run build" gave me a tiny CSS file. Mine was about 64 KB gzipped.
When the rebuild didn’t catch something, I stopped and restarted the dev server. Old school trick. Still works.
Things that bit me (so you don’t get bit)
- Missing content paths. I forgot to add “./components” at first. Tailwind didn’t see the classes inside there. No build, no styles. Easy fix. (See the official content configuration docs for how the scanner works.)
- Classes made from variables. Like "bg-${color}". Tailwind can’t read that. I had to use safelist. Or switch to CSS variables.
- Extra slow on a big repo. On my old laptop, file watch made the fan spin. On the Air, it was fine. If it drags, trim your content globs.
- IntelliSense lag. The VS Code plugin didn’t show my new colors until I saved tailwind.config.js. Save it again if it acts weird.
A tiny performance note
Dev CSS was huge, like a few megabytes. That’s normal. After "npm run build", it shrank a lot. My page felt snappy. No flash between saves on Vite. Only a small blink when I changed big layouts. Pretty smooth.
Stripping out unused framework CSS can shave off even more; I did something similar in WordPress by axing Gutenberg’s bundle and documented the gains in this write-up.
If you’re curious how a production-scale adult social network keeps its pages lightweight yet feature-rich using similar utility-first tactics, swing by Fuckbook—exploring their live UI can give you practical inspiration for balancing performance with interaction-heavy components.
Likewise, if you want to see how a city-specific escort directory leans on clean utility classes to present dozens of profile cards without bogging down load times, check out Slixa Pasadena—the listing page is a great real-world example of responsive grids, filter panels, and subtle hover interactions that you can study and adapt for your own builds.
A small digression: making charts match
I use Chart.js. I wanted chart colors to match Tailwind. I used the same hex codes from theme.extend. I kept them in a tiny "theme.ts" file. Less guessing. More trust.
When you should rebuild
- You add new files or folders with classes.
- You use odd values (like p-[13px]) and Tailwind didn’t pick them up.
- You moved classes into strings or data.
- You added plugins (forms, typography, or something like daisyUI).
If you do that and still see nothing, restart dev. Then check content paths again. Nine times out of ten, it’s that.
My verdict
I was stuck. Rebuilding Tailwind and extending the config set me free. I got the odd sizes, the fancy grid, and clean buttons. The work took an hour. The payoff lasts.
Would I do it again? Yep. It felt like getting a fresh set of crayons when the old ones were down to nubs.
Quick cheat sheet
- Use custom values: p-[13px], w-[15%], aspect-[4/3]
- Extend theme for repeat stuff: colors, spacing
- Safelist classes you build from data
- Keep content paths tight and correct
- Add a components layer with @apply for shared styles
- Restart dev if it acts grumpy
And if you ever have to squeeze custom snippets into a hosted editor like Website.com, I recorded what sticks and what doesn’t right here.
If you’re stuck like I was—just rebuild Tailwind, teach it your shapes and colors, and keep going. It’s not fancy. It just