Setting up Tailwind CSS with VitePress is quite straightforward. Below is a step-by-step guide to help you integrate Tailwind CSS into your VitePress project.
Step 1: Initialize VitePress Project
If you haven't already set up a VitePress project, you can start by creating a new directory and installing VitePress.
This imports your Tailwind built CSS into VitePress theme.
Step 6: Run VitePress Dev Server
Now, run your development server to see Tailwind CSS take effect:
bash
npm run docs:dev
Open the browser at the address (usually http://localhost:3000).
Try adding Tailwind classes in your markdown like:
md
# Hello World
<div class="text-2xl font-bold text-blue-600">
This text is styled by Tailwind!
</div>
Summary
Install VitePress
Install Tailwind CSS and PostCSS dependencies
Configure Tailwind to scan docs/*.md and .vitepress files
Add Tailwind's directives to your custom CSS (index.css)
Import that CSS in your VitePress custom theme
Run VitePress dev and use Tailwind classes!
If you want, I can also provide a minimal example repo structure or help with specific configuration issues. Just ask!
User
vite. How to configure tailwind if i'm using their latest.
Assistant
If you're using the latest Vite (not just VitePress) and want to configure Tailwind CSS in a vanilla Vite project, here’s the up-to-date way to do it with Tailwind CSS 3.x+ and Vite 4.x+.
Step-by-step: Configure Tailwind CSS in a Latest Vite Project
1. Create a new Vite project (if you don’t have one already)
If you want me to provide the exact config for e.g. Vue or React with Vite + Tailwind, let me know!
User
tailwind 4.1
Assistant
Tailwind CSS v4.1 is very recent (as of mid-2024), and setup with Vite is mostly the same as Tailwind v3.x and v4.0, with some small improvements or fixes. The integration with Vite hasn't fundamentally changed, but there are some updated recommendations from Tailwind themselves.
Setting up Tailwind CSS v4.1 with the latest Vite
1. Initialize your Vite project if you don't have one
You should create the Tailwind configuration files and related files in the root of your Vite project (the top-level directory where your package.json lives).
Explanation of where to create each file:
File
Location (relative to your project root)
Purpose
tailwind.config.js
project root (same folder as package.json)
Tailwind CSS config file
postcss.config.js
project root
PostCSS config, used by Vite
src/index.css
Inside src folder or wherever your main CSS lives
Your Tailwind input CSS styles
src/main.js (entry)
Inside src/ (or wherever your main JS/TS entry point is)
Import the Tailwind CSS file
Typical project structure might look like:
code
my-vite-project/
├── package.json
├── tailwind.config.js <-- here
├── postcss.config.js <-- here
├── index.html
├── vite.config.js
└── src/
├── main.js <-- import './index.css' here
└── index.css <-- your Tailwind directives here
Summary:
Always put tailwind.config.js & postcss.config.js at root, next to package.json.
Put your Tailwind CSS input (with @tailwind directives) somewhere inside your source, often src/index.css.
Import that CSS file in your entry point (src/main.js or similar).
If you’re working with VitePress, the config placement varies slightly, e.g.:
Tailwind config still at project root
CSS typically in .vitepress/theme/index.css or a similar .vitepress folder
Import CSS in .vitepress/theme/index.js
But for plain latest Vite (vanilla/project), root is the right place.
Let me know if you want me to illustrate the folder setup based on your specific framework or tool!
User
i did that but it still purges classes
Assistant
If Tailwind CSS is purging classes you want to keep, it usually means that the content paths in the tailwind.config.js are not set correctly, so Tailwind cannot detect classes used in your source files.
Common reasons why Tailwind might purge too aggressively
Incorrect content paths — Tailwind can't find your HTML, JS, Vue, or markdown files that contain the class names.
Classes are generated dynamically (e.g. class={"text-" + color}), which Tailwind’s extractor can't detect unless safelisted.
Using Markdown or Vue files with embedded classes but not adding their paths in the content array.
CSS files imported but no classes used in files inside the configured content glob.
What to do step-by-step
1. Verify your tailwind.config.js content paths include all relevant files
Use dev tools (Chrome/Firefox) to inspect the button element.
See which CSS rules are applying, their source, and which have higher specificity.
This helps pinpoint exactly what CSS is overriding Tailwind utilities.
User
how to do second?
Assistant
Great! Here's how to make sure your Tailwind CSS styles load after any other global CSS so Tailwind utilities (like padding, background-color, etc.) are not overridden by other button styles — i.e., adjust the CSS import order.
Step-by-step: Fix CSS Import Order in a Vite (or VitePress) project
1. Locate your global CSS imports
Usually, you have:
Some global CSS file(s) or reset CSS (like normalize.css, reset.css, or a global styles file)
Your Tailwind CSS file (the one with @tailwind base; @tailwind components; @tailwind utilities;)
Maybe some UI library CSS or theme CSS (like VitePress default theme styles)
In Vite (vanilla / React / Vue etc.), typically you import CSS files in your main JavaScript/TypeScript entry file (e.g., src/main.js, src/main.ts, src/main.jsx, src/main.tsx, or index.js) e.g.:
js
// Example in src/main.js
import 'normalize.css' // 1. base/reset comes first
import './global.css' // 2. your global styles (resets or overrides)
import './index.css' // 3. Tailwind CSS (import last!)
2. Import Tailwind CSS after other CSS files
Tailwind includes utility classes and base styles that you want to take precedence.
If you import Tailwind’s CSS before other styles that have rules like:
those later styles will override your Tailwind utilities because of CSS cascade/order.
Solution: Import Tailwind CSS file last in your main entry to give it highest priority.
3. Example for your main entry file (e.g., src/main.js)
js
import './reset.css' // some reset CSS if any
import './global.css' // your global styles (might contain button resets)
import './index.css' // your Tailwind CSS import (must be last for priority)
User
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import './style.css'
import CarbonButton from '../components/CarbonButton.vue'
import CarbonBadge from '../components/CarbonBadge.vue'
import CarbonChange from '../components/CarbonChange.vue'
import ItemsReference from '../components/ItemsReference.vue'
import EntitiesReference from '../components/EntitiesReference.vue'
import EntityPage from '../components/EntityPage.vue'
import PrefabReference from '../components/PrefabReference.vue'
import PrefabPage from '../components/PrefabPage.vue'
import BlueprintsReference from '../components/BlueprintsReference.vue'
import ItemPage from '../components/ItemPage.vue'
import BlueprintPage from '../components/BlueprintPage.vue'
import LootTableList from '../components/LootTableList.vue'
import CarbonIcons from '../components/CarbonIcons.vue'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import HooksIndex from '../components/HooksIndex.vue'
import HooksDetails from '../components/HooksDetails.vue'
import CommandReference from '../components/CommandReference.vue'
import ConVarReference from '../components/ConVarReference.vue'
import SwitchesReference from '../components/SwitchesReference.vue'
import ReleaseNotesReference from '../components/ReleaseNotesReference.vue'
import RustConVarReference from '../components/RustConVarReference.vue'
import RustCommandReference from '../components/RustCommandReference.vue'
import CarbonProducts from '../components/CarbonProducts.vue'
import CarbonBuildsDownloads from '../components/CarbonBuildsDownloads.vue'
Assistant
Thanks for sharing part of your .vitepress/theme/index.js file.
From your snippet, I see this line already:
js
import './style.css'
To ensure Tailwind CSS has the highest priority over other global styles, you need to:
Make sure style.css contains your Tailwind directives:
Make sure no other CSS files override Tailwind styles after this import in your .vitepress/theme/index.js.
If you import any other CSS in this file or in VitePress config, make sure they come beforeimport './style.css'.
If you have any global CSS files imported elsewhere (e.g., via docs/.vitepress/config.js or vite.config.js), check their order.
You can double-check the load order like this:
js
// docs/.vitepress/theme/index.js
// import any other global/reset CSS first:
import '../some-global.css'
// import Tailwind CSS last to override them properly:
import './style.css'
import DefaultTheme from 'vitepress/theme'
export default {
...DefaultTheme,
// your theme config here
}
Additional tips:
If you find button styles like this overriding Tailwind:
that are possibly coming from VitePress's default styles or some custom global CSS, ensure your Tailwind CSS is loaded after or override these styles in your custom CSS.
Troubleshooting with DevTools
Open browser DevTools → Inspect the button.
Look at the CSS rules applied and note which files or stylesheets define the conflicting button CSS.
Trace the origin of those styles.
Adjust import order so your Tailwind styles load after those stylesheets.
Summary:
Make sure style.css has Tailwind directives.
Import only one CSS file for Tailwind, and import it last in your theme entry file.
If other global styles exist, import them beforestyle.css.
Restart the VitePress dev server after changes.
If you want, you can share your current complete .vitepress/theme/index.js and style.css or any global CSS imports, and I can review the exact import order for you!
User
import { defineConfig } from "vitepress";
import autoprefixer from "autoprefixer";
import { tabsMarkdownPlugin } from "vitepress-plugin-tabs";
import { ITEMS_API_URL, HOOKS_API_URL, BLUEPRINTS_API_URL } from "./shared/constants";
import tailwindcss from "@tailwindcss/vite";
1. It's NOT necessary to use the Tailwind plugin for Vite explicitly in VitePress (or Vite).
The official Tailwind CSS + Vite integration is generally done via postcss.config.js and importing the CSS with @tailwind directives — using tailwindcss() as a Vite plugin is uncommon in this setup and can sometimes cause issues.
You can safely remove the tailwindcss() plugin from here and instead stick to importing your Tailwind CSS stylesheet directly.
2. The key thing for Tailwind to work well in VitePress is:
You create a CSS file in .vitepress/theme (e.g. style.css or index.css) that contains:
Styling with utility classes
Hover, focus, and other states
Responsive design
Dark mode
Theme variables
Colors
Adding custom styles
Detecting classes in source files
Functions and directives
Base styles
code
Preflight
Layout
code
aspect-ratio
columns
break-after
break-before
break-inside
box-decoration-break
box-sizing
display
float
clear
isolation
object-fit
object-position
overflow
overscroll-behavior
position
top / right / bottom / left
visibility
z-index
It looks like you’ve shared the official Tailwind CSS installation instructions for Vite from their docs, including this approach:
Installing Tailwind CSS as a Vite Plugin (from Tailwind's latest recommended method)
Install dependencies:
bash
npm install tailwindcss @tailwindcss/vite
Update your vite.config.ts or vite.config.js:
js
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(), // add Tailwind Vite plugin here
],
})
Import Tailwind in your CSS file:
css
@import "tailwindcss";
Run your dev server: npm run dev
Important Notes & How This Differs From The Classic Setup
New Tailwind Vite Plugin (@tailwindcss/vite) lets Tailwind inject CSS automatically during the Vite build, removing the need for separate PostCSS config.
The CSS import is simplified to@import "tailwindcss";instead of using the usual 3 @tailwind base; ...; utilities; directives.
This approach simplifies setup for Vite users.
So when to use this approach?
If you want the new official Vite plugin for Tailwind CSS (@tailwindcss/vite) which handles styles behind the scenes.
It’s particularly useful if you want to avoid having a postcss.config.js file.
How to apply this to your VitePress project (based on what you've shared):
Install:
bash
npm install tailwindcss @tailwindcss/vite
Update vitepress.config.js’s vite plugins:
js
User
so how to resolve my issue?
Assistant
Thanks for the detailed context! To resolve your issue with Tailwind CSS being overridden by button styles in your VitePress project using the new @tailwindcss/vite plugin, let's clarify and fix your setup step-by-step.
Your issue summary
Your buttons have default/global styles (like padding: 0; background-color: transparent) that override Tailwind utilities.
You're using the new Tailwind Vite plugin (@tailwindcss/vite) and importing Tailwind with @import "tailwindcss"; in your .vitepress/theme/style.css.
Tailwind classes seem to get purged or overridden.
How to fix it (step-by-step)
1. Ensure your CSS import order is correct
In .vitepress/theme/index.js, import your Tailwind CSS file last to ensure Tailwind overrides other styles:
js
import DefaultTheme from 'vitepress/theme'
// if you have any reset or global styles, import them first here, e.g.
// import './global.css'
import './style.css' // Tailwind CSS import with @import "tailwindcss";
export default {
...DefaultTheme,
}
2. Customize or reset the button styles after Tailwind’s styles
Even with correct import order, VitePress (or other global styles) applies base styles like:
// https://vitepress.dev/guide/custom-theme
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import './style.css'
import CarbonButton from '../components/CarbonButton.vue'
import CarbonBadge from '../components/CarbonBadge.vue'
import CarbonChange from '../components/CarbonChange.vue'
import ItemsReference from '../components/ItemsReference.vue'
import EntitiesReference from '../components/EntitiesReference.vue'
import EntityPage from '../components/EntityPage.vue'
import PrefabReference from '../components/PrefabReference.vue'
import PrefabPage from '../components/PrefabPage.vue'
import BlueprintsReference from '../components/BlueprintsReference.vue'
import ItemPage from '../components/ItemPage.vue'
import BlueprintPage from '../components/BlueprintPage.vue'
import LootTableList from '../components/LootTableList.vue'
import CarbonIcons from '../components/CarbonIcons.vue'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import HooksIndex from '../components/HooksIndex.vue'
import HooksDetails from '../components/HooksDetails.vue'
import CommandReference from '../components/CommandReference.vue'
import ConVarReference from '../components/ConVarReference.vue'
import SwitchesReference from '../components/SwitchesReference.vue'
import ReleaseNotesReference from '../components/ReleaseNotesReference.vue'
import RustConVarReference from '../components/RustConVarReference.vue'
import RustCommandReference from '../components/RustCommandReference.vue'
import CarbonProducts from '../components/CarbonProducts.vue'
import CarbonBuildsDownloads from '../components/CarbonBuildsDownloads.vue'
Your .vitepress/theme/index.ts (or .js) looks good regarding component registration and theme extension.
To resolve the issue with Tailwind CSS being overridden by default button styles in VitePress, here’s a focused checklist and concrete instructions for your setup:
1. Ensure you have a style.css file in .vitepress/theme/ with Tailwind imported correctly
Example .vitepress/theme/style.css:
css
/* Import Tailwind CSS via the Vite plugin method */
@import "tailwindcss";
/* Override global button styles to avoid being overridden by defaults */
button {
@apply px-4 py-2 bg-blue-600 text-white font-semibold rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500;
}
The key is: use @import "tailwindcss"; only if you're using the @tailwindcss/vite plugin in your vitepress.config.js (which you do).
Then override button styles with Tailwind's utilities via the @apply directive to reset button default padding/background set by VitePress.
2. Import style.css in your theme entry file (your shared code shows import './style.css' - good).
This ensures the styles are bundled into your site.
3. Confirm your VitePress config enables the Tailwind Vite plugin
Perfect — so your Tailwind should be injected via the Vite plugin.
4. Restart your dev server to clear caches:
bash
npm run docs:dev
5. Verify in browser DevTools:
Inspect a <button>.
Check if the styles from your override appear.
User
if i do @apply - it changes buttongs
Assistant
Yes, exactly — using @apply with Tailwind utility classes inside your CSS explicitly overrides the default button styles and applies the Tailwind styles consistently. This is the recommended way to "reset" or style buttons globally with Tailwind when some other CSS (like VitePress's base styles) conflicts with Tailwind utilities.
Why @apply changes buttons and that's expected:
By default, browsers and some UI frameworks/VitePress apply minimal/reset styles to buttons such as padding: 0, background: transparent, font-family: inherit, etc.
Tailwind's utility classes like px-4 py-2 bg-blue-600 rounded add padding, background color, border-radius, font styles etc.
Using @apply in CSS tells Tailwind to take those utilities and generate CSS rules for buttons, overriding the base reset styles.
Without this explicit override, buttons will keep those minimal styles and utilities won’t affect padding/background etc. because of CSS cascade and specificity.
In short:
If your buttons are looking plain/un-styled because of CSS resets, using @apply on button in your CSS is the correct fix.
This ensures buttons use Tailwind’s padding, colors, rounding, and other utilities consistently across your docs.
How to implement it safely
In your .vitepress/theme/style.css:
css
@import "tailwindcss";
/* Make global button styles use Tailwind utilities */
button {
@apply px-4 py-2 bg-blue-600 text-white font-semibold rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500;
}
If you want to avoid globally styling every button (which might be too aggressive), use a class approach:
@apply is how you "upgrade"/reset buttons with Tailwind utilities.
It will change buttons — that's the point, to apply your custom Tailwind styles.
This is the proper way to ensure Tailwind styles win over default or base CSS resets.
If you want full control, use a utility class instead of styling all buttons globally.
Let me know if you want a sample minimal repro or specific advice on your button components!
User
So how could we resolve overide issue?
Cuz there is a lot of elements that get overidden
Assistant
Great question! When you have many elements affected by global base/reset styles (like VitePress’s built-in resets) overriding your Tailwind utilities, you want a scalable way to ensure Tailwind's styles apply consistently without having to write @apply rules for every element manually.
How to properly resolve the override issue in VitePress + Tailwind setup
1. Understand Tailwind's Preflight Reset (Included in @tailwind base)
Tailwind includes Preflight, its own minimal CSS reset and base styles designed to work well with Tailwind utilities.
This resets many elements (including buttons) but also applies some sensible defaults and ensures Tailwind utilities are reliable.
2. Ensure Tailwind’s Preflight is loaded after any other CSS reset or global base styles
If you’re using any other CSS reset (normalize.css, or VitePress’s default global styles), make sure Tailwind's Preflight CSS is loaded last using proper order of CSS imports.
In VitePress:
Your .vitepress/theme/style.css must include:
css
@import "tailwindcss";
Tailwind’s @import "tailwindcss" via plugin will inject @tailwind base, @tailwind components, @tailwind utilities.
Make sure no other global CSS (resets or overrides) are included after this file.
3. Avoid conflicting styles by not loading multiple CSS resets
If VitePress ships with global reset styles that conflict:
Either override those styles yourself (see below),
Or disable/hide conflicting base CSS if possible.
Tailwind’s Preflight includes standard resets; adding another reset can cause conflicts.
4. Override selectively with Tailwind utilities using layered custom CSS
For example, create your own layer after Tailwind like:
is coming from VitePress’s internal base.css / base.js (preflight/base styles), here’s how to handle it properly:
What is happening?
VitePress ships its own built-in base/reset styles loaded globally via base.js (or base.css), which include CSS resets on elements like buttons, inputs, etc.
These base styles reset buttons to padding: 0, background: transparent, etc.
Tailwind’s Preflight (injected via @import "tailwindcss";) also resets elements but differently.
The CSS cascade order and specificity combined causes VitePress’s base styles to override Tailwind utility styles unless you override them.
How to fix it properly?
1. Your .vitepress/theme/style.css imported after VitePress base styles
This should already be the case when you import your style.css only in .vitepress/theme/index.js, because VitePress loads its base styles before any theme styles.
So your Tailwind styles and overrides can have higher CSS priority.
2. Overriding the base styles with Tailwind utilities
Since VitePress base resets buttons to padding: 0, you'll need to explicitly override those styles.
import './index.css'
// your app code here using tailwind classes
If you are sure your config is correct but classes still get purged:
Check for typos in class names in source files.
Ensure files are saved — unsaved changes won't be seen by Tailwind.
Sometimes glob patterns may miss files if you have uppercase/lowercase issues or files outside configured paths.
If you want, share your current tailwind.config.js and folder structure and I can help double-check!
Option 5: Use Tailwind’s preflight (included in @tailwind base)
Note: Tailwind includes a reset called Preflight in @tailwind base that normalizes and resets elements, including buttons. If this global reset you found is not from Tailwind but from other CSS, it can conflict.
Make sure you:
are actually including @tailwind base; in your main CSS file,
and don't have conflicting CSS loaded after Tailwind CSS.
Make sure your CSS import order in your JS entry file looks like:
js
import './index.css' // import AFTER any other global styles
Check your project for other global CSS or UI libraries that might be setting the button CSS.
Use browser dev tools to identify what CSS overrides Tailwind button styles.
Fix by either:
Overriding the conflicting styles manually,
Adjusting import order,
Using Tailwind’s utility modifier ! if needed.
If you want to, you can share:
Your CSS import setup,
Any global CSS or reset CSS you're using,
The HTML for the button you're trying to style,
and I can help give you a tailored fix!
4. If you do not have other CSS files:
Make sure you’re not importing or including any third-party/global CSS (via vite.config.js or HTML) that sets base styles after Tailwind CSS.
5. VitePress specific:
In VitePress, you usually import styles inside .vitepress/theme/index.js.
Make sure the order inside .vitepress/theme/index.js is:
js
import 'other-global.css' // If you have any base styles globally
import './index.css' // Your Tailwind CSS file with @tailwind directives, imported last!
export default {
// theme config...
}
6. Bonus: Using DevTools to Check Source Order
In your browser DevTools (Elements tab), inspect the button.
Find its CSS rules.
Check which CSS file or stylesheet the "button { padding: 0; }" rule is coming from.
See the order of CSS files under Sources tab or Network tab.
This helps confirm if your Tailwind CSS is loaded before the overriding CSS.
Summary:
Import order in main JS
Effect on CSS specificity / priority
Tailwind CSS imported first, then your global CSS
Your globals override Tailwind utilities (bad)
Your global CSS imported first, then Tailwind CSS
Tailwind utilities win — button styles work right
If you share your current import setup (your main.js or .vitepress/theme/index.js) I can help you fix the order specifically!
TL;DR for Vite (vanilla example):
js
// src/main.js
import './reset.css' // 1. Load resets / base CSS first
import './global.css' // 2. Load other global styles next
import './index.css' // 3. Load Tailwind CSS LAST — ensure your utilities override others
Tailwind CSS works by scanning all of your HTML files, JavaScript components, and any other templates for class names, generating the corresponding styles and then writing them to a static CSS file.
It's fast, flexible, and reliable — with zero-runtime.
Installation
code
Using Vite
Using PostCSS
Tailwind CLI
Framework Guides
Play CDN
Installing Tailwind CSS as a Vite plugin
Installing Tailwind CSS as a Vite plugin is the most seamless way to integrate it with frameworks like Laravel, SvelteKit, React Router, Nuxt, and SolidJS.
01
Install Tailwind CSS
Install tailwindcss and @tailwindcss/vite via npm.
Terminal
npm install tailwindcss @tailwindcss/vite
02
Configure the Vite plugin
Add the @tailwindcss/vite plugin to your Vite configuration.
vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
03
Import Tailwind CSS
Add an @import to your CSS file that imports Tailwind CSS.
CSS
@import "tailwindcss";
04
Start your build process
Run your build process with npm run dev or whatever command is configured in your package.json file.
Terminal
npm run dev
05
Start using Tailwind in your HTML
Make sure your compiled CSS is included in the (your framework might handle this for you), then start using Tailwind’s utility classes to style your content.
HTML
Are you stuck? Setting up Tailwind with Vite can be a bit different across different build tools. Check our framework guides to see if we have more specific instructions for your particular setup.
Explore our framework guides
Learn
VitePress’s theme injects global styles you might want to override.
You can create or extend .vitepress/theme/styles/index.css or inject styles via .vitepress/theme/index.js.
Summary of best practice to fix overrides:
Step
Action
1
Ensure only Tailwind's Preflight CSS reset applies globally
2
Import your CSS with @import "tailwindcss"; last
3
Avoid other conflicting CSS resets imported after Tailwind
4
Override problem elements globally via button { @apply ... }
5
Prefer utility classes in components/templates
6
Safelist classes dynamically generated/purged by Tailwind
7
Customize VitePress theme CSS to avoid conflicting global rules
If the scale of overrides is big, the best scalable approach is:
Control styling mostly through Tailwind utility classes in your components & pages (instead of global CSS).
Add minimal @apply overrides only for truly default elements that need fixing.
If you want, I can help audit your project's global CSS, Tailwind config, and VitePress theme styles to tailor a fix! Just share your CSS and config files.
Use Tailwind’s @apply directive here to generate robust CSS that wins over VitePress’s base styles by virtue of either source order or specificity.
3. Alternatively: use utility classes on elements themselves
Rather than styling button globally, you can style buttons individually in your components or Markdown pages with inline classes:
html
<button class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
Click me
</button>
This is usually preferred to avoid having a "one global button style" that may conflict with various UI parts.
4. If needed, increase specificity or use !important
Not ideal, but sometimes necessary if other styles are very specific:
Or increase specificity by using html body button or class selectors.
5. Confirm correct content paths in tailwind.config.js
Make sure Tailwind scans all your .vue, .md, .js, .ts files including those inside .vitepress folder so purge does not remove used classes.
6. Debug with DevTools
In browser devtools, inspect buttons.
See what CSS rules apply and from which stylesheet (VitePress base vs Tailwind).
This tells you if your override CSS is actually loaded and why something is still overridden.
Summary
What to do
Why
Write explicit overrides for reset styles on elements (like buttons)
Because VitePress base CSS resets styles
Import your Tailwind CSS and style overrides in .vitepress/theme/style.css
Theme styles load after VitePress base by default
Use Tailwind @apply or utility classes to enforce styles
Utility classes override base reset better
Prefer per-element utility classes in markup when possible
Minimizes global conflicts
If you want, I can help craft a minimal example patch for your .vitepress/theme/style.css that specifically fixes buttons, form elements, and other commonly overridden elements.