🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Comparisons••By Komal Nakrani

Tailwind vs CSS in Astro: Which Should You Use?

Tailwind vs CSS in Astro compared: setup, scoped styles, bundle size, maintenance and team fit, with the same component built both ways and a clear verdict.

#Astro#Tailwind CSS#CSS#Styling

For Tailwind vs CSS in Astro, both are first-class: Astro scopes plain <style> blocks to each component automatically, and Tailwind CSS installs with one command through its Vite plugin. Choose Tailwind when a team builds many pages fast from a shared design system; choose plain CSS when you want fewer dependencies, readable markup, and Astro’s built-in scoping to do the isolation work.

Key Takeaways

  • Astro’s scoped <style> removes the main problem utility CSS was invented to solve: class name collisions.
  • Tailwind ships only the utilities you use, so final CSS size is small for both approaches.
  • Tailwind is faster for prototyping and consistent spacing; plain CSS is easier to read and has no build dependency.
  • You can mix them: Tailwind for layout and spacing, scoped CSS for complex component styles.

What Astro gives you before you add anything

Plain CSS in Astro is not plain CSS in a static HTML file. Every <style> block inside an .astro component is scoped by default. Astro adds a unique attribute to the component’s elements and rewrites your selectors to match, so .card in one component never leaks into another.

---
// src/components/Card.astro
const { title, href } = Astro.props;
---
<a class="card" href={href}>
  <h3>{title}</h3>
  <slot />
</a>

<style>
  .card {
    display: block;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
  }
  .card:hover {
    border-color: var(--accent);
  }
  h3 {
    margin: 0 0 0.5rem;
  }
</style>

The h3 selector above only affects headings inside this card. Astro also bundles, minifies and splits the CSS per page during astro build, and supports is:global for global styles and define:vars for passing frontmatter values into CSS custom properties. The Astro styling guide covers all of it in depth.

Setting up Tailwind in Astro

Tailwind CSS 4 runs as a Vite plugin. The astro add command installs it and wires up the config:

npx astro add tailwind

That produces a config like this:

// astro.config.mjs
import { defineConfig } from 'astro/config';
import tailwindcss from '@tailwindcss/vite';

export default defineConfig({
  vite: {
    plugins: [tailwindcss()],
  },
});

And a global stylesheet you import in your layout:

/* src/styles/global.css */
@import "tailwindcss";

@theme {
  --color-accent: #6d28d9;
  --font-display: "Inter", sans-serif;
}
---
// src/layouts/Base.astro
import '../styles/global.css';
---
<html lang="en">
  <body><slot /></body>
</html>

Older projects on Tailwind 3 use the @astrojs/tailwind integration and a tailwind.config.mjs file instead. Both work in Astro 7, but new projects should use the Vite plugin. The Tailwind setup docs for Astro track the current steps.

Tailwind vs CSS compared

Plain CSS (scoped) Tailwind CSS
Setup None One command, one CSS import
Dependencies None tailwindcss, @tailwindcss/vite
Scoping Automatic per component Not needed; utilities are global and atomic
Final CSS size Grows with your styles Grows with the number of distinct utilities used
Markup readability Clean HTML, styles below Long class lists
Design consistency Up to your custom properties Built-in scale for spacing, color, type
Responsive and states Media queries, :hover in CSS md:, hover:, dark: prefixes inline
Learning curve CSS knowledge only CSS plus Tailwind’s vocabulary
Refactoring Rename in one place Find and replace class strings
Long-term risk None; CSS is a web standard Major versions change config and syntax

Two rows deserve more detail.

Final CSS size. Tailwind scans your files and generates only the utilities you used. On a large site, the total stays fairly flat because p-4 costs the same whether you use it once or a thousand times. Scoped CSS grows with every component, but Astro splits it per page, so each page only loads the styles of components it renders. In practice both end up small on a typical content site. Measure your own dist/ rather than relying on general claims.

Long-term risk. Tailwind 3 to 4 moved configuration from JavaScript to CSS (@theme) and changed how plugins load. Plain CSS has no such migrations. For a client site you hand over and rarely touch, that matters.

The same component both ways

A pricing card, styled with Tailwind:

---
// src/components/PriceCard.astro
const { name, price, features } = Astro.props;
---
<article class="rounded-2xl border border-zinc-200 p-6 shadow-sm hover:border-violet-600 dark:border-zinc-800">
  <h3 class="text-lg font-semibold">{name}</h3>
  <p class="mt-2 text-4xl font-bold tracking-tight">${price}</p>
  <ul class="mt-6 space-y-2 text-sm text-zinc-600 dark:text-zinc-400">
    {features.map((f) => <li>{f}</li>)}
  </ul>
</article>

The same card with scoped CSS:

---
// src/components/PriceCard.astro
const { name, price, features } = Astro.props;
---
<article class="price-card">
  <h3>{name}</h3>
  <p class="price">${price}</p>
  <ul>
    {features.map((f) => <li>{f}</li>)}
  </ul>
</article>

<style>
  .price-card {
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  }
  .price-card:hover { border-color: var(--accent); }
  h3 { font-size: 1.125rem; font-weight: 600; }
  .price { margin-top: 0.5rem; font-size: 2.25rem; font-weight: 700; }
  ul { margin-top: 1.5rem; display: grid; gap: 0.5rem; color: var(--muted); }
</style>

The Tailwind version is shorter and you never leave the markup. The CSS version reads more clearly when you come back in six months, and dark mode is handled once by redefining --border, --accent and --muted instead of adding dark: to every element.

Where each approach wins

Tailwind wins on

  • Speed of building pages. You style while you write markup, with no context switch and no naming.
  • Consistency across a team. The spacing and color scale stops five developers from inventing five shades of gray.
  • Responsive work. grid-cols-1 md:grid-cols-3 is faster to write than a media query block.
  • Prototyping and landing pages. One-off sections with unique layouts don’t need reusable class names.

Plain CSS wins on

  • Readable markup. Content-heavy templates stay easy to scan.
  • Complex components. Animations, :has() selectors, grid template areas and container queries are clearer in a stylesheet.
  • Zero dependencies. No plugin upgrades, no config migrations, nothing to break on npm update.
  • Styling Markdown and MDX output. Rendered content has no classes, so you style h2, p and pre with element selectors anyway (or use the Tailwind Typography plugin’s prose class).

Modern CSS has also closed much of the gap. Native nesting, custom properties, clamp() for fluid type, cascade layers and container queries all work in current browsers without a build step. Our define:vars tip shows how to feed frontmatter values into custom properties.

Mixing both in one Astro project

You don’t have to choose all or nothing. A common pattern is Tailwind for layout and spacing utilities, plus a scoped <style> block for the parts that are awkward as utilities.

---
// src/components/Hero.astro
---
<section class="mx-auto max-w-5xl px-6 py-24 text-center">
  <h1 class="hero-title">Ship a fast site this week</h1>
  <slot />
</section>

<style>
  .hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    background: linear-gradient(90deg, var(--color-accent), #db2777);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
</style>

In Tailwind 4 you can also read Tailwind’s theme variables from scoped CSS, because @theme exposes them as CSS custom properties such as var(--color-accent). That keeps one source of truth for colors and fonts.

Choose Tailwind or plain CSS

Choose Tailwind if you work in a team, build many pages from a shared component set, or already think in utility classes. It is also the faster path for marketing sites and landing pages with lots of unique sections.

Choose plain scoped CSS if you are a solo developer or small team, the site is mostly content, you want the fewest dependencies, or you are handing the site to a client who may edit it later without knowing Tailwind.

Mix them if you like Tailwind for layout but have components with animations or complex selectors. Astro handles both in the same file without conflict.

Most Komal themes use Tailwind CSS 3 for layout plus Astro components, so if you buy one you can keep that setup or add scoped styles where you prefer. To compare finished designs before deciding, browse the Astro themes and open any live preview. For theme-specific styling notes, see the styling and design tokens docs, and for a broader decision tree, the styling approach guide.

FAQ

Is Tailwind better than CSS?

Neither is better in general. Tailwind is faster for building many pages with a consistent design system, and plain CSS is more readable and has no dependencies. In Astro, scoped styles remove the class collision problem, so the choice comes down to team workflow and preference.

Does Tailwind make Astro sites slower?

No. Tailwind generates only the utility classes your files use, and Astro bundles and minifies the result, so the CSS shipped is typically small. Tailwind adds no client-side JavaScript. Build time increases slightly because Tailwind scans your source files.

Do I need Tailwind if Astro has scoped styles?

No. Scoped <style> blocks give you component isolation without any library. Tailwind adds a utility vocabulary and a design scale on top. Many Astro sites use only scoped CSS and custom properties.

Can I use Tailwind and regular CSS together in Astro?

Yes. Import Tailwind once in a global stylesheet and keep writing scoped <style> blocks in components. In Tailwind 4, theme values defined with @theme are available as CSS custom properties, so scoped CSS can use the same colors and fonts.

Should I use the @astrojs/tailwind integration or the Vite plugin?

Use the @tailwindcss/vite plugin for Tailwind 4, which is what npx astro add tailwind sets up in current Astro versions. The @astrojs/tailwind integration is for Tailwind 3 projects and is no longer the recommended path for new sites.