Custom Styling
CZON supports customizing site styles through the .czon/style.css file, allowing you to override default styles or add a personalized appearance.
How to Use
- Create a
style.cssfile in the.czondirectory of your project:
your-project/
├── .czon/
│ ├── meta.json
│ └── style.css <-- Create this file
├── README.md
└── docs/
- Write your custom CSS in
style.css:
/* Example: Change link color */
:root {
--link-color: #0066cc;
}
/* Example: Modify background in dark mode */
html.dark {
--bg-primary: #0d1117;
}
- Re-run
czon build, and the custom styles will automatically apply to all pages.
How It Works
- During build, CZON checks if
.czon/style.cssexists. - If it exists, it is copied to the output directory
.czon/dist/style.css. - In each generated HTML page, a stylesheet link is added within the
<head>:<link rel="stylesheet" href="style.css" /> - Custom styles are loaded after the built-in styles, allowing them to override defaults.
Available CSS Variables
CZON uses CSS variables to define theme colors. You can quickly adjust the color scheme by overriding these variables:
:root {
/* Background colors */
--bg-primary: #ffffff;
--bg-secondary: #f8f9fa;
--bg-tertiary: #e9ecef;
/* Text colors */
--text-primary: #333333;
--text-secondary: #6c757d;
--text-muted: #adb5bd;
/* Link and accent colors */
--link-color: #007bff;
--link-hover-color: #0056b3;
/* Border colors */
--border-color: #dee2e6;
}
/* Dark mode variables */
html.dark {
--bg-primary: #1a1a1a;
--bg-secondary: #2d2d2d;
--bg-tertiary: #404040;
--text-primary: #e5e5e5;
--text-secondary: #a0a0a0;
--text-muted: #6c6c6c;
--link-color: #58a6ff;
--link-hover-color: #79b8ff;
--border-color: #404040;
}
Examples
Custom Brand Colors
:root {
--link-color: #e91e63;
--link-hover-color: #c2185b;
}
html.dark {
--link-color: #f48fb1;
--link-hover-color: #f8bbd9;
}
Adjust Content Area Width
.content {
max-width: 60rem;
}
Custom Code Block Styling
pre code {
font-family: 'Fira Code', 'JetBrains Mono', monospace;
font-size: 0.875rem;
}
Hide Specific Elements
/* Hide the right sidebar table of contents */
.sidebar-right {
display: none;
}
Notes
- The custom stylesheet filename must be
style.cssand placed in the.czon/directory. - After modifying styles, you need to re-run
czon buildfor changes to take effect. - It is recommended to customize styles by overriding CSS variables, as this ensures compatibility with both light and dark modes.
- CZON uses Tailwind CSS. If you need to override styles generated by Tailwind, you may need to use
!important.