Documentation
On this page
Install Cirth for Fresh
Fresh 2's client.ts is the browser entry point. It loads
assets/styles.css as the app's global stylesheet. Cirth comes in from npm
through Deno, as one @import at the top of that file.
Three steps: install, import it and check it.
1 Install #
deno add npm:@cirthcss/cirth
deno install
deno install puts the package in node_modules/, where Vite resolves a
stylesheet's @import.
2 Import it #
At the top of assets/styles.css:
@import "@cirthcss/cirth";
Fresh's Vite build keeps Cirth's light-dark() colours, so there is no CSS
target to set.
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.
Routes and islands render ordinary Preact elements, styled as they are.
Customization covers the --cirth-* properties; set
yours after the @import in assets/styles.css. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.