Skip to main content
Build extension UI surfaces quickly with utility classes across popup, options, new tab, sidebar, and content-script entries. Extension.js integrates Tailwind through PostCSS and supports both Tailwind v3 and v4 setups.

When Tailwind CSS is a good fit

  • You need fast UI iteration across multiple extension surfaces.
  • You prefer utility-first styling with shared tokens.
  • You want consistent styling patterns across page and content-script entries.

Tailwind capabilities

Template examples

Use this template when you want a complete Tailwind setup in a real extension UI surface. sidebar-shadcn screenshot
Repository: examples/sidebar-shadcn

Usage with an existing extension

Installation

Install the required dependencies:

Configuration

Create postcss.config.js:
For Tailwind v3 projects, use tailwindcss as the PostCSS plugin and keep a tailwind.config.js content list.

Tailwind v4 vs v3 quick setup

Tailwind content paths (v3 style)

Usage

Create a global stylesheet and import Tailwind:

Create the global CSS file

Import this file in entry scripts that use Tailwind classes.

In a page script (popup/options/new-tab)

In a content script

Tailwind compiles the stylesheet at build time, and the script loads it into the shadow root. A plain import "./styles/globals.css" styles nothing in a content script. See CSS, Sass, and Less for every route.

Body fonts on extension pages

Chrome adds its own stylesheet to extension pages. That stylesheet sets the body font family to system-ui, sans-serif and the font size to 75%, and it is not in a cascade layer. Styles outside a layer beat layered styles, so a font that you set only in @layer base does not reach body or the elements inside it. Set the body font in a rule outside any layer:
The :root prefix makes the rule win in whatever order the stylesheets load. Keep your other base styles in @layer base.

Best practices

  • Keep Tailwind source imports in shared style entry files (styles/globals.css).
  • Ensure your content scanning includes pages/, scripts/, and src/ when relevant.
  • In monorepos, verify Tailwind content paths resolve from the extension project root.
  • Use templates when possible to avoid configuration drift between PostCSS and Tailwind versions.

Next steps

  • Configure PostCSS for additional CSS transforms.
  • Ensure your CSS follows best practices with Stylelint.