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, and the Tailwind CSS configuration is consistent with 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, which avoids conflicts with Tailwind CSS classes. You can freely use Tailwind v4 or v3 without worrying about style collisions.
Install dependencies
Create PostCSS config
Create a postcss.config.mjs file in the root of your project:
Create Tailwind CSS file
Create a tailwind.css file in the root of your project:
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:
Usage
Now you can use Tailwind utility classes in your MDX files: