Nextra is fully compatible with Tailwind CSS v4, the modern utility-first CSS framework. BecauseDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
nextra-theme-docs ships its own Tailwind-generated classes, you can safely add Tailwind v4 to your project without worrying about conflicts — both sets of styles coexist cleanly through standard CSS cascade rules and @layer ordering.
Installation
Tailwind CSS v4 no longer requires a
tailwind.config.js file. Configuration is done
entirely through CSS using directives like @theme and @utility.Import Tailwind into your
globals.css file using the new v4 CSS import syntax. You can also
import your Nextra theme styles in the same file:@import "tailwindcss";
/* Import Nextra theme styles */
@import "nextra-theme-docs/style.css";
/* Required for Nextra dark mode variant support */
@variant dark (&:where(.dark *));
Custom Utilities with @utility
Tailwind CSS v4 introduces the @utility directive, which lets you define custom utility classes that integrate natively with Tailwind’s engine — including variant support, arbitrary values, and JIT compilation.
globals.css
hover:content-auto, lg:tab-4) and are only included in the output if actually used.
Cascade Layers and nextra-theme-docs
nextra-theme-docs uses Tailwind CSS v4 internally and outputs styles within CSS @layer declarations. Understanding how cascade layers interact helps you override theme styles predictably.
Default style import
By default, when you importnextra-theme-docs/style.css, its styles are placed into Tailwind’s standard layers. Your custom styles added outside a layer always win over layered styles:
globals.css
Using @layer for explicit ordering
When you need fine-grained control, declare explicit layer ordering before any imports. Layers declared later in the @layer statement have higher priority:
globals.css
CSS layer isolation with style-prefixed.css
nextra-theme-docs also ships a style-prefixed.css variant. Whereas style.css uses the standard Tailwind v4 layer names (@layer base and @layer utilities), style-prefixed.css renames those layers to v4-base and v4-utilities. This prevents accidental merging with your own base or utilities layers when both sets of styles are loaded in the same cascade:
globals.css
Coexistence with nextra-theme-docs
A common concern is whether adding Tailwind CSS to your project will conflict with the Tailwind classes already used bynextra-theme-docs. The short answer is: they do not conflict.
nextra-theme-docs ships pre-compiled CSS — it does not re-run the Tailwind compiler at your project’s build time. Your project’s Tailwind instance only scans and processes files you configure (your app/ directory, components, etc.). The two sets of generated classes live independently in the final CSS output.
If you see unexpected style conflicts, check your
@layer ordering. Styles outside any
@layer always take precedence over layered styles, so moving your overrides outside a
layer is often the simplest fix.Full example
Here is a complete setup combining Tailwind CSS v4 withnextra-theme-docs:
- globals.css
- postcss.config.mjs
- app/layout.tsx