Skip to content
Nilay Kabariya

Entry No.008·Fixes·Updated ·3 min read

Cannot apply unknown utility class border-border in Tailwind v4

Three causes trigger this Tailwind v4 error, each with its own fix: custom colours, CSS modules and Vue/Svelte styles, and v3 classes. All reproduced.

by Nilay#tailwind#css#shadcn#vite#vueFIXED

The error, verbatim

Jump to the fix ↓
Error: Cannot apply unknown utility class `border-border`

Error: Cannot apply unknown utility class `font-bold`. Are you using
CSS modules or similar and missing `@reference`?
✓ Reproduced on Windows 11 Pro

Tested on

tailwindcss
4.3.3
CLI / Vite
@tailwindcss/cli 4.3.3; @tailwindcss/vite 4.3.3, Vite 8.3.5, Vue 3 SFC (October 31)
Node / npm
24.14.0 / 11.9.0
OS
Windows 11 Pro
Contents
  1. The fix01
  2. In a Vue or Svelte component02
  3. Still using tailwind.config.js colours?03
  4. Which v3 class names still work04
  5. Why it happens05
  6. Why @reference and not @import06
  7. What didn’t work07
  8. How this was tested08

The fix

First look at which class the error names. That tells you which of three causes you have.

The class is a custom name like border-border, bg-background or text-foreground (common with shadcn/ui). Tailwind v4 only knows colours declared in @theme. Map your CSS variable into it:

@import "tailwindcss";

:root {
  --border: oklch(0.92 0 0);
}

@theme inline {
  --color-border: var(--border);
}

@layer base {
  * {
    @apply border-border;
  }
}

The class is a normal one like font-bold, and the file is a CSS module, a Vue or Svelte <style> block, or any CSS file that doesn’t import Tailwind. Add @reference at the top of that file:

@reference "tailwindcss";

.title {
  @apply font-bold text-xl;
}

If your main CSS defines its own theme, reference that file instead, for example @reference "../app.css";. That way your custom colours work inside the module too.

The class is an old v3 name like bg-opacity-50 or text-opacity-50. Tailwind v4 removed the opacity utilities. Put the opacity on the colour instead:

.overlay {
  @apply bg-black/50 text-white/50;
}

In a Vue or Svelte component

In a Vite project the error names the component’s style block, which tells you it’s cause 2:

[plugin @tailwindcss/vite:generate:build] .../src/App.vue?vue&type=style&index=0&scoped=e1d6a330&lang.css
Error: Cannot apply unknown utility class `font-bold`. Are you using CSS modules or similar and missing `@reference`?

The @reference path is resolved from the component file, not from the project root. With App.vue and main.css both in src/, @reference "../main.css" failed with a second error:

Error: Can't resolve '../main.css' in '...\src'

Still using tailwind.config.js colours?

If your border, background and similar colours live in an old tailwind.config.js, you don’t have to move them into @theme today. Load the config from your CSS:

@import "tailwindcss";
@config "./tailwind.config.js";

Which v3 class names still work

Not every renamed utility breaks @apply. On Tailwind 4.3.3, the opacity utilities failed and these old names still worked:

@apply Tailwind 4.3.3
bg-opacity-50, text-opacity-50 ❌ unknown utility class
flex-shrink-0, flex-grow ✅ still works
overflow-ellipsis, decoration-slice ✅ still works
shadow-sm ✅ still works

Why it happens

In v4, @apply can only use utilities that Tailwind knows about in that file, and only ones v4 still has.

  • Case 1: border-border isn’t a built-in class. It only exists once a --color-border theme variable is defined. Setups copied from Tailwind v3 defined these colours in tailwind.config.js, and v4 ignores that file unless you add @config.
  • Case 2: Tailwind processes each CSS module and component style block on its own. Those files never ran @import "tailwindcss", so even font-bold is unknown there. Tailwind v4’s own message now suggests @reference for exactly this case.

Why @reference and not @import

@import "tailwindcss" inside the module also makes the error go away, but it copies Tailwind’s base styles into every module that does it:

5,585 B

module with @import

base styles copied in

617 B

module with @reference

only .title

9×

bigger output

@reference lets the file use Tailwind’s theme without outputting it.

What didn’t work

How this was tested

Tailwind 4.3.3 on Windows 11 Pro with Node 24.14.0: each case built with @tailwindcss/cli, then the component case in a Vite 8.3.5 project with Vue 3 and @tailwindcss/vite. First tested September 22, re-tested and extended on October 31, 2026. Error messages are copied from the runs. The script and the output are public.

— N.K., end of entry No.008

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.017

    Fix: Failed to load PostCSS config (module is not defined) in Vite

    Vite can't load your PostCSS config, sometimes one you didn't know existed. The three causes, how to tell which you have from the message, and what fixes each.

    > [plugin vite:css] C:/project/src/style.css

    FIXED6 min
  2. No.007

    Fix: npx tailwindcss init “could not determine executable to run”

    npx tailwindcss init fails on a fresh install. Why Tailwind v4 does this, two fixes that work, and the command that fails silently. Reproduced.

    > $ npx tailwindcss init

    FIXED2 min
  3. No.080

    Fix: No 'Access-Control-Allow-Origin' header is present

    Blocked by CORS policy, but Postman and curl work fine. Five versions of the error reproduced in Chrome with Express and Vite, and which fix fits each.

    > Access to fetch at 'http://localhost:3001/plain/data' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    FIXED3 min

Post card · Every Sunday

What broke this week.

One email on Sundays: the Node, TypeScript, Python and AI SDK releases that broke builds that week, each one reproduced, with a link to the fix that worked. Never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text