Skip to main content
Documentation
On this page

Install Cirth for Elysia

Elysia serves files with its static plugin. Cirth's package is a folder of finished CSS, so the server can expose that folder from node_modules at a public URL. A <link> in the returned document loads it for the whole page.

Verified with Elysia 1.4.30 on

Three steps: install, serve it and link it and check it.

1 Install #

bun add @cirthcss/cirth @elysiajs/static
import { Elysia } from "elysia";
import { staticPlugin } from "@elysiajs/static";

const page = `<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/cirth/cirth.min.css">
    <title>Elysia</title>
  </head>
  <body>
    <main class="container"><h1>Hello, Elysia</h1></main>
  </body>
</html>`;

new Elysia()
  .use(staticPlugin({ assets: "node_modules/@cirthcss/cirth/dist", prefix: "/cirth" }))
  .get("/", ({ set }) => {
    set.headers["content-type"] = "text/html; charset=utf-8";
    return page;
  })
  .listen(3000);

The plugin sends the file as text/css, unchanged. A JSX or template plugin writes the same <link>.

3 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>

Run the app, 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.

Customization covers the --cirth-* properties; set yours in a stylesheet loaded after Cirth's. 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.