Skip to main content
Documentation
On this page

Install Cirth for Waku

A new Waku app imports src/styles.css from its root layout, and that file imports Tailwind. Cirth takes Tailwind's place, and Waku's Vite settings take one line.

Verified with Waku 1.0.0-rc.2 on

Four steps: install, import it, configure Vite and check it.

1 Install #

Package manager
npm install @cirthcss/cirth
pnpm add @cirthcss/cirth
yarn add @cirthcss/cirth
bun add @cirthcss/cirth

Remove Tailwind, which styles the same elements from the other direction:

npm uninstall tailwindcss @tailwindcss/vite

2 Import it #

Replace the contents of src/styles.css:

@import "@cirthcss/cirth";

src/pages/_layout.tsx already imports that file.

3 Configure Vite #

Vite compiles CSS for browsers older than Cirth supports. That process rewrites light-dark() colours. The page can still follow the system theme, but a data-theme region may fail to force the other colour scheme. Set Vite to Cirth's browser floor below. Compatibility explains the transformation and its limits.

Add build.cssTarget under vite in waku.config.ts, with the tailwindcss() plugin removed:

import { defineConfig } from "waku/config";
import react from "@vitejs/plugin-react";

export default defineConfig({
  vite: {
    build: {
      cssTarget: ["chrome123", "edge123", "firefox130", "safari18.2"],
    },
    plugins: [react()],
  },
});

Keep any other plugin the starter lists there.

4 Check it #

Put this forced-dark region in a page or component that uses the global stylesheet:

<section data-theme="dark">
  <article>
    <p>Dark, whatever the system scheme is.</p>
  </article>
</section>

Build for production, then open the page while the system uses a light theme. A dark article proves that Cirth loaded and that data-theme="dark" is working. It remains dark when the system switches to a dark theme. If the article follows the surrounding page instead, the build rewrote Cirth's colours: check the CSS target above.

Customization covers the --cirth-* properties; set yours after the @import in src/styles.css. Package and builds lists the classless, scoped and print entry points. Return to Framework guides for another stack.

Search documentation

Type at least two characters to search.