All jobs

Add Tailwind CSS to a Leptos App

Yes. An agent switches your Leptos app from the starter's SCSS to a Tailwind input that cargo-leptos builds, moves the styles to classes, rebuilds, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads how styles reach the page today, because in a Leptos project the build tool owns that. In an app made from leptos-rs/start-axum, Cargo.toml depends on leptos 0.8.0, leptos_router, leptos_meta, an optional axum 0.8.0 and leptos_axum behind the ssr feature, and wasm-bindgen 0.2.106 behind hydrate; the [package.metadata.leptos] table sets style-file = "style/main.scss", assets-dir = "public", site-root = "target/site", site-pkg-dir = "pkg" and site-addr = "127.0.0.1:3000". style/main.scss holds two rules, a sans-serif font and centred text on body. src/app.rs injects the compiled file with <Stylesheet id="leptos" href="/pkg/{{project-name}}.css"/> inside App, and HomePage renders an h1 and a button that counts clicks. README.md says cargo-leptos compiles the SCSS with dart-sass and that cargo leptos watch is the development loop.

Then it reads what cargo-leptos can do instead of compiling SCSS. Its configuration takes tailwind-input-file, which turns on a Tailwind build, and an optional tailwind-config-file; the tool downloads the standalone tailwindcss binary itself, so there is no package.json to add at the project root, and the version can be pinned with LEPTOS_TAILWIND_VERSION. The agent therefore adds no Node toolchain and keeps the end2end directory, with its own package.json and Playwright config, as the only place npm runs.

The change is four files. Cargo.toml replaces style-file with tailwind-input-file = "style/tailwind.css". That new file imports Tailwind and points its content scan at src/**/*.rs, so class names written inside view! macros are found and the output is only the utilities the app uses. style/main.scss is deleted, and its two rules become font-sans and text-center on body in shell(), with a few classes on the h1 and the button in HomePage to prove the pipeline end to end. The output file keeps the name {{project-name}}.css under pkg, so the Stylesheet line in src/app.rs does not change and hot reload keeps working through its id="leptos".

The agent proves it by building. cargo leptos build downloads the Tailwind binary on first use, compiles the server with the ssr feature and the WebAssembly bundle with hydrate, and writes target/site/pkg/{{project-name}}.css; the agent reads that file to confirm it contains the text-center rule and nothing from a stylesheet that no longer exists. It then starts the server binary from target, requests / and checks the <link> and the h1 text, and runs end2end/tests/example.spec.ts with Playwright's Chromium against http://localhost:3000, since that test asserts the title Welcome to Leptos and the heading text, both of which the restyle must leave alone. cargo fmt --all --check runs last because view! blocks were edited.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add Tailwind CSS to this Leptos application. Read Cargo.toml including its [package.metadata.leptos] table, README.md, rust-toolchain.toml, src/app.rs, src/main.rs, src/lib.rs, style/main.scss, end2end/package.json, end2end/playwright.config.ts and end2end/tests/example.spec.ts first. Use cargo-leptos's own Tailwind support: replace style-file with tailwind-input-file = \"style/tailwind.css\", create that file importing Tailwind with its content scan set to src/**/*.rs, delete style/main.scss and move its body rules to font-sans and text-center classes in shell(), and add a few utility classes to the h1 and button in HomePage. Do not add a package.json or Node tooling at the project root; cargo-leptos downloads the tailwindcss binary. Run cargo leptos build, confirm the output CSS under target/site/pkg contains the utilities you used, start the built server and check / renders, run the Playwright test in end2end against it with Chromium, and run cargo fmt --all --check. Open a pull request that explains how the CSS is built now and what a developer runs locally.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is a pull request that changes Cargo.toml and src/app.rs, adds style/tailwind.css and deletes style/main.scss. The description explains the new build path in three sentences: cargo-leptos runs the Tailwind binary on the input file, scans the Rust sources for class names, and writes the same pkg file the Stylesheet component already loads, so cargo leptos watch is still the only command a developer runs.

The run's record holds the cargo leptos build output including the Tailwind download, the lines of the generated CSS the agent checked, the server's response to / and the Playwright result, so a reviewer can see the styled page was served rather than trust the diff.

Before merging, a reviewer decides whether to pin the Tailwind version with LEPTOS_TAILWIND_VERSION in CI, and whether to keep dart-sass in the README's tool list now that nothing compiles SCSS. The agent updates the README line about styles and leaves the install list for the reviewer.

Run it on every Linear issue labelled frontend

A team that tracks UI work in Linear adds an automation on the Project with a linear trigger filtered to the label frontend and a prompt written for the general case: the trigger adds the issue after the prompt, so the run reads which components the issue names and styles those with Tailwind classes once the pipeline exists. Each labelled issue starts one run and a pull request comes back linked from it.

The automation runs as the member who last changed it and needs that member's Linear connection, made once under Settings → Connections. Its max_runs_per_hour cap keeps a grooming session that labels many issues from starting them all in the same minute.

The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.

Why run it on Rush?

The thing that goes wrong with Tailwind in a Rust project is the content scan: a class written inside a view! macro that the scanner never reads produces no CSS and an unstyled page with no error. The agent builds in its own sandbox, reads the generated stylesheet for the classes it used, and loads the page in a browser, so the pull request shows the pipeline works instead of assuming it.

Every command stays with the run, from the Tailwind binary download to the Playwright output, and the pull request can cite them. Doing the same for several Leptos apps at once costs no more attention than one, because each run has its own machine and its own record.

Frequently asked questions

Do I need Node or npm at the project root now?

No. cargo-leptos downloads the standalone tailwindcss binary when tailwind-input-file is set and runs it as part of cargo leptos build and watch. The only package.json in the repository stays in end2end, where Playwright lives.

Does the Stylesheet line in app.rs change?

No. The Tailwind output is written to the same pkg path with the project's name, which is what <Stylesheet id="leptos" href="/pkg/{{project-name}}.css"/> already points at, and the id is what cargo leptos watch uses to hot-reload the stylesheet.

What about the existing SCSS?

style/main.scss has two rules on body, both of which exist as Tailwind utilities, so the file is deleted and the classes go on the body element in shell(). A larger SCSS file could be kept by leaving style-file set alongside tailwind-input-file, which the agent mentions in the pull request as the path for a bigger app.

Will the Playwright test still pass?

Yes. end2end/tests/example.spec.ts checks the page title and the h1 text, and the restyle changes classes, not text. The agent runs that test against the built server with Chromium and includes the result in the run's record.

More Leptos jobs

More jobs like this: Turn a Linear label into a PR

Keep reading