Documentation
On this page
Install Cirth for Flask
Flask serves the static/ folder next to your app at public URLs. The base
template supplies the document head for every template that extends it, so
one Cirth link there applies across the site.
Three steps: add the file, link it and check it.
1 Add the file #
mkdir -p static/css
curl -o static/css/cirth.min.css \
https://cdn.jsdelivr.net/npm/@cirthcss/cirth@0.17.0/dist/cirth.min.css
2 Link it #
In templates/base.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ url_for('static', filename='css/cirth.min.css') }}">
<title>{% block title %}My site{% endblock %}</title>
</head>
<body>
<main class="container">{% block content %}{% endblock %}</main>
</body>
</html>
In production, let the web server in front of Flask serve static/
directly, with a long cache lifetime and the version in the file name or
query string.
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 linked after Cirth. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.