Tailwind CSS
Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces. It can be used with MDX files in Rspress to help you style your documentation more efficiently, for example:
Rspress is built on Rsbuild, so Tailwind CSS v4 can be integrated with the same Rsbuild plugin recommended by Rsbuild. For more details, see:
Below is a guide for integrating Tailwind CSS v4 with Rspress.
All Rspress built-in components use BEM naming conventions and do not use Tailwind CSS internally. Your project owns the Tailwind CSS dependency and build plugin, which avoids version conflicts with Rspress.
Install dependencies
Create Tailwind CSS file
Create a tailwind.css file in the root of your project:
Tailwind CSS v4 is not designed to be used with CSS preprocessors like Sass, Less, or Stylus. Keep @import 'tailwindcss'; at the beginning of a .css file.
Rspress toggles dark mode by checking the .dark class on the html element, so you need to configure @custom-variant. See Tailwind Docs - Dark Mode for details.
Configure Rspress
In your rspress.config.ts, use the globalStyles option to import the Tailwind CSS file:
If your project already has a PostCSS setup, you can also follow the Rsbuild guide to use @tailwindcss/postcss instead.
Usage
Now you can use Tailwind utility classes in your MDX files: