Documentation
On this page
Install Cirth for Angular
Angular loads global stylesheets from the styles array of the build
configuration. Cirth is one entry there.
Four steps: install, add it to the build, write HTML and check it.
1 Install #
npm install @cirthcss/cirth
pnpm add @cirthcss/cirth
yarn add @cirthcss/cirth
bun add @cirthcss/cirth
2 Add it to the build #
In angular.json, under your project's architect.build.options, put Cirth
before your own stylesheet so your rules come after it:
"styles": [
"node_modules/@cirthcss/cirth/dist/cirth.min.css",
"src/styles.css"
]
The array takes file paths, so use the path to the file rather than the
package name. Alternatively, import it at the top of src/styles.css, where
the package name works:
@import "@cirthcss/cirth";
Angular's default build keeps Cirth's light-dark() colours as they are, so
there is no CSS target to set.
3 Write HTML #
Component templates render ordinary elements:
<main class="container">
<article>
<header><h1>Hello, Angular</h1></header>
<label>
Name
<input name="name" autocomplete="name">
</label>
<footer><button type="submit">Save</button></footer>
</article>
</main>
Cirth styles the global document. A component whose styles are encapsulated
in a shadow root (ViewEncapsulation.ShadowDom) does not receive global CSS;
use the default emulated encapsulation for markup Cirth should style.
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>
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 src/styles.css, after Cirth. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.